diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:12:43 +0000 |
commit | cf94bdc0742c13e2a0cac864c478b8626b266e1b (patch) | |
tree | 044670aa50cc5e2b4229aa0b6b3df6676730c0a6 /compiler/rustc_lint/src/traits.rs | |
parent | Adding debian version 1.65.0+dfsg1-2. (diff) | |
download | rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.tar.xz rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.zip |
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_lint/src/traits.rs')
-rw-r--r-- | compiler/rustc_lint/src/traits.rs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/compiler/rustc_lint/src/traits.rs b/compiler/rustc_lint/src/traits.rs index df1587c59..f22f38aa2 100644 --- a/compiler/rustc_lint/src/traits.rs +++ b/compiler/rustc_lint/src/traits.rs @@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { use rustc_middle::ty::PredicateKind::*; - let predicates = cx.tcx.explicit_predicates_of(item.def_id); + let predicates = cx.tcx.explicit_predicates_of(item.owner_id); for &(predicate, span) in predicates.predicates { let Trait(trait_predicate) = predicate.kind().skip_binder() else { continue @@ -100,15 +100,18 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { if trait_predicate.trait_ref.self_ty().is_impl_trait() { continue; } - cx.struct_span_lint(DROP_BOUNDS, span, |lint| { - let Some(needs_drop) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { - return - }; - lint.build(fluent::lint::drop_trait_constraints) - .set_arg("predicate", predicate) - .set_arg("needs_drop", cx.tcx.def_path_str(needs_drop)) - .emit(); - }); + let Some(needs_drop) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { + continue; + }; + cx.struct_span_lint( + DROP_BOUNDS, + span, + fluent::lint_drop_trait_constraints, + |lint| { + lint.set_arg("predicate", predicate) + .set_arg("needs_drop", cx.tcx.def_path_str(needs_drop)) + }, + ); } } } @@ -119,14 +122,11 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { }; for bound in &bounds[..] { let def_id = bound.trait_ref.trait_def_id(); - if cx.tcx.lang_items().drop_trait() == def_id { - cx.struct_span_lint(DYN_DROP, bound.span, |lint| { - let Some(needs_drop) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { - return - }; - lint.build(fluent::lint::drop_glue) - .set_arg("needs_drop", cx.tcx.def_path_str(needs_drop)) - .emit(); + if cx.tcx.lang_items().drop_trait() == def_id + && let Some(needs_drop) = cx.tcx.get_diagnostic_item(sym::needs_drop) + { + cx.struct_span_lint(DYN_DROP, bound.span, fluent::lint_drop_glue, |lint| { + lint.set_arg("needs_drop", cx.tcx.def_path_str(needs_drop)) }); } } |