diff options
| author | Michael Goulet <michael@errs.io> | 2022-09-25 22:23:36 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-10-20 17:31:01 +0000 |
| commit | 8509819aef02c28c3f636dc04ad7b6087f7dc334 (patch) | |
| tree | cfff3bcc6dbc2fcb71ec48696390cca67469d1ba /src/test | |
| parent | 542febd2d383b5082277c7d165b098c0a3b513f6 (diff) | |
| download | rust-8509819aef02c28c3f636dc04ad7b6087f7dc334.tar.gz rust-8509819aef02c28c3f636dc04ad7b6087f7dc334.zip | |
Elaborate supertrait bounds when triggering unused_must_use on impl Trait
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/lint/unused/unused-supertrait.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/lint/unused/unused-supertrait.stderr | 15 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/lint/unused/unused-supertrait.rs b/src/test/ui/lint/unused/unused-supertrait.rs new file mode 100644 index 00000000000..64a8e520457 --- /dev/null +++ b/src/test/ui/lint/unused/unused-supertrait.rs @@ -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 +} diff --git a/src/test/ui/lint/unused/unused-supertrait.stderr b/src/test/ui/lint/unused/unused-supertrait.stderr new file mode 100644 index 00000000000..d2f8c007848 --- /dev/null +++ b/src/test/ui/lint/unused/unused-supertrait.stderr @@ -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 + |
