X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_lint%2Fsrc%2Fmultiple_supertrait_upcastable.rs;h=c2ed0e19f4011e5aa70221716ac318107c57f237;hb=5e958293e3d2bf3ee0b7e9101ea33c385ab704bc;hp=5861b826b1ca337309631b1ed4c5e0947f9adaf7;hpb=c52d58f346aea2e2e7ed650ee95785d33500a6d0;p=rust.git diff --git a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs index 5861b826b1c..c2ed0e19f40 100644 --- a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs +++ b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs @@ -1,6 +1,5 @@ use crate::{LateContext, LateLintPass, LintContext}; -use rustc_errors::DelayDm; use rustc_hir as hir; use rustc_span::sym; @@ -37,8 +36,10 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { let def_id = item.owner_id.to_def_id(); + // NOTE(nbdd0121): use `object_safety_violations` instead of `check_is_object_safe` because + // the latter will report `where_clause_object_safety` lint. if let hir::ItemKind::Trait(_, _, _, _, _) = item.kind - && cx.tcx.is_object_safe(def_id) + && cx.tcx.object_safety_violations(def_id).is_empty() { let direct_super_traits_iter = cx.tcx .super_predicates_of(def_id) @@ -46,16 +47,12 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { .into_iter() .filter_map(|(pred, _)| pred.to_opt_poly_trait_pred()); if direct_super_traits_iter.count() > 1 { - cx.struct_span_lint( + cx.emit_spanned_lint( MULTIPLE_SUPERTRAIT_UPCASTABLE, cx.tcx.def_span(def_id), - DelayDm(|| { - format!( - "`{}` is object-safe and has multiple supertraits", - item.ident, - ) - }), - |diag| diag, + crate::lints::MultipleSupertraitUpcastable { + ident: item.ident + }, ); } }