Elaborate supertrait bounds when triggering unused_must_use on impl Trait

This commit is contained in:
Michael Goulet 2022-09-25 22:23:36 +00:00
parent 542febd2d3
commit 8509819aef
3 changed files with 32 additions and 2 deletions

View file

@ -0,0 +1,11 @@
#![deny(unused_must_use)]
fn it() -> impl ExactSizeIterator<Item = ()> {
let x: Box<dyn ExactSizeIterator<Item = ()>> = todo!();
x
}
fn main() {
it();
//~^ ERROR unused implementer of `Iterator` that must be used
}

View file

@ -0,0 +1,15 @@
error: unused implementer of `Iterator` that must be used
--> $DIR/unused-supertrait.rs:9:5
|
LL | it();
| ^^^^^
|
= note: iterators are lazy and do nothing unless consumed
note: the lint level is defined here
--> $DIR/unused-supertrait.rs:1:9
|
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
error: aborting due to previous error