Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test for #[must_use] on traits
  • Loading branch information
varkor committed Nov 19, 2018
1 parent cb5520b commit 1228868
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/ui/lint/must_use-trait.rs
@@ -0,0 +1,22 @@
#![deny(unused_must_use)]

#[must_use]
trait Critical {}

trait NotSoCritical {}

trait DecidedlyUnimportant {}

struct Anon;

impl Critical for Anon {}
impl NotSoCritical for Anon {}
impl DecidedlyUnimportant for Anon {}

fn get_critical() -> impl NotSoCritical + Critical + DecidedlyUnimportant {
Anon {}
}

fn main() {
get_critical(); //~ ERROR unused implementer of `Critical` that must be used
}
14 changes: 14 additions & 0 deletions src/test/ui/lint/must_use-trait.stderr
@@ -0,0 +1,14 @@
error: unused implementer of `Critical` that must be used
--> $DIR/must_use-trait.rs:21:5
|
LL | get_critical(); //~ ERROR unused implementer of `Critical` that must be used
| ^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/must_use-trait.rs:1:9
|
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^

error: aborting due to previous error

0 comments on commit 1228868

Please sign in to comment.