1+ #![ deny( rustc:: untranslatable_diagnostic) ]
2+ #![ deny( rustc:: diagnostic_outside_of_impl) ]
3+ use crate :: lints:: { DropGlue , DropTraitConstraintsDiag } ;
14use crate :: LateContext ;
25use crate :: LateLintPass ;
36use crate :: LintContext ;
4- use rustc_errors:: fluent;
57use rustc_hir as hir;
68use rustc_span:: symbol:: sym;
79
@@ -101,17 +103,13 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
101103 if trait_predicate. trait_ref . self_ty ( ) . is_impl_trait ( ) {
102104 continue ;
103105 }
104- let Some ( needs_drop ) = cx. tcx . get_diagnostic_item ( sym:: needs_drop) else {
105- continue ;
106+ let Some ( def_id ) = cx. tcx . get_diagnostic_item ( sym:: needs_drop) else {
107+ return
106108 } ;
107- cx. struct_span_lint (
109+ cx. emit_spanned_lint (
108110 DROP_BOUNDS ,
109111 span,
110- fluent:: lint_drop_trait_constraints,
111- |lint| {
112- lint. set_arg ( "predicate" , predicate)
113- . set_arg ( "needs_drop" , cx. tcx . def_path_str ( needs_drop) )
114- } ,
112+ DropTraitConstraintsDiag { predicate, tcx : cx. tcx , def_id } ,
115113 ) ;
116114 }
117115 }
@@ -123,12 +121,11 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
123121 } ;
124122 for bound in & bounds[ ..] {
125123 let def_id = bound. trait_ref . trait_def_id ( ) ;
126- if cx. tcx . lang_items ( ) . drop_trait ( ) == def_id
127- && let Some ( needs_drop) = cx. tcx . get_diagnostic_item ( sym:: needs_drop)
128- {
129- cx. struct_span_lint ( DYN_DROP , bound. span , fluent:: lint_drop_glue, |lint| {
130- lint. set_arg ( "needs_drop" , cx. tcx . def_path_str ( needs_drop) )
131- } ) ;
124+ if cx. tcx . lang_items ( ) . drop_trait ( ) == def_id {
125+ let Some ( def_id) = cx. tcx . get_diagnostic_item ( sym:: needs_drop) else {
126+ return
127+ } ;
128+ cx. emit_spanned_lint ( DYN_DROP , bound. span , DropGlue { tcx : cx. tcx , def_id } ) ;
132129 }
133130 }
134131 }
0 commit comments