提交 cb5520bc 编写于 作者: V varkor

Recognise #[must_use] on traits, affecting impl Trait

上级 b55717f9
...@@ -66,9 +66,22 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { ...@@ -66,9 +66,22 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
} else { } else {
match t.sty { match t.sty {
ty::Adt(def, _) => check_must_use(cx, def.did, s.span, ""), 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, _ => false,
} }
} };
let mut fn_warned = false; let mut fn_warned = false;
let mut op_warned = false; let mut op_warned = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册