diff options
| author | varkor <github@varkor.com> | 2018-11-03 20:08:30 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-11-19 17:41:10 +0000 |
| commit | cb5520bc4865473971281ddb3e33a29a256109c8 (patch) | |
| tree | b09c2eaca5ac8274b4a5cefa474d299229530452 | |
| parent | b55717f9b0023f58b7ca2fab77a0b33206076ac4 (diff) | |
| download | rust-cb5520bc4865473971281ddb3e33a29a256109c8.tar.gz rust-cb5520bc4865473971281ddb3e33a29a256109c8.zip | |
Recognise #[must_use] on traits, affecting impl Trait
| -rw-r--r-- | src/librustc_lint/unused.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 6383ca69fe5..f8030fa6ec7 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -66,9 +66,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { } else { match t.sty { ty::Adt(def, _) => check_must_use(cx, def.did, s.span, ""), + ty::Opaque(def, _) => { + let mut must_use = false; + for (predicate, _) in cx.tcx.predicates_of(def).predicates { + if let ty::Predicate::Trait(ref poly_trait_predicate) = predicate { + let trait_ref = poly_trait_predicate.skip_binder().trait_ref; + if check_must_use(cx, trait_ref.def_id, s.span, "implementer of ") { + must_use = true; + break; + } + } + } + must_use + } _ => false, } - } + }; let mut fn_warned = false; let mut op_warned = false; |
