Skip to content

Commit

Permalink
Recognise #[must_use] on traits, affecting impl Trait
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Nov 19, 2018
1 parent b55717f commit cb5520b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/librustc_lint/unused.rs
Expand Up @@ -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;
Expand Down

0 comments on commit cb5520b

Please sign in to comment.