forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#102287 - compiler-errors:unused-must-use-al…
…so-supertrait, r=fee1-dead Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait` Given `impl Trait`, if one of its supertraits has a `#[must_use]`, then trigger the lint. This means that, for example, `-> impl ExactSizeIterator` also triggers the `must_use` on `trait Iterator`, which fixes rust-lang#102183. This might need `@rust-lang/lang` sign-off, since it changes the behavior of the lint, so cc'ing them.
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: unused implementer of `Iterator` that must be used | ||
--> $DIR/unused-supertrait.rs:9:5 | ||
| | ||
LL | it(); | ||
| ^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/unused-supertrait.rs:1:9 | ||
| | ||
LL | #![deny(unused_must_use)] | ||
| ^^^^^^^^^^^^^^^ | ||
= note: iterators are lazy and do nothing unless consumed | ||
|
||
error: aborting due to previous error | ||
|