Skip to content

Commit 2d95dfd

Browse files
niacdoialjoshtriplett
authored andcommitted
unused_must_use: Add extra test for types that are still generic
1 parent 339caa1 commit 2d95dfd

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

tests/ui/lint/unused/must_use-result-unit-uninhabited.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ fn main() {
9191
controlflow_infallible_unit();
9292
controlflow_never();
9393
}
94+
95+
trait AssocTypeBeforeMonomorphisation {
96+
type Error;
97+
fn generate(&self) -> Result<(), Self::Error>;
98+
fn process(&self) {
99+
self.generate(); //~ ERROR: unused `Result` that must be used
100+
}
101+
}

tests/ui/lint/unused/must_use-result-unit-uninhabited.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,17 @@ help: use `let _ = ...` to ignore the resulting value
6262
LL | let _ = controlflow_unit();
6363
| +++++++
6464

65-
error: aborting due to 5 previous errors
65+
error: unused `Result` that must be used
66+
--> $DIR/must_use-result-unit-uninhabited.rs:99:9
67+
|
68+
LL | self.generate();
69+
| ^^^^^^^^^^^^^^^
70+
|
71+
= note: this `Result` may be an `Err` variant, which should be handled
72+
help: use `let _ = ...` to ignore the resulting value
73+
|
74+
LL | let _ = self.generate();
75+
| +++++++
76+
77+
error: aborting due to 6 previous errors
6678

0 commit comments

Comments
 (0)