unused_must_use: Add extra test for types that are still generic

This commit is contained in:
niacdoial 2025-10-06 08:21:34 -07:00 committed by Josh Triplett
parent 339caa11c7
commit 2d95dfd5a9
2 changed files with 21 additions and 1 deletions

View file

@ -91,3 +91,11 @@ fn main() {
controlflow_infallible_unit();
controlflow_never();
}
trait AssocTypeBeforeMonomorphisation {
type Error;
fn generate(&self) -> Result<(), Self::Error>;
fn process(&self) {
self.generate(); //~ ERROR: unused `Result` that must be used
}
}

View file

@ -62,5 +62,17 @@ help: use `let _ = ...` to ignore the resulting value
LL | let _ = controlflow_unit();
| +++++++
error: aborting due to 5 previous errors
error: unused `Result` that must be used
--> $DIR/must_use-result-unit-uninhabited.rs:99:9
|
LL | self.generate();
| ^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = self.generate();
| +++++++
error: aborting due to 6 previous errors