1
+ #![ deny( rustc:: untranslatable_diagnostic) ]
2
+ #![ deny( rustc:: diagnostic_outside_of_impl) ]
3
+ use crate :: lints:: { DropGlue , DropTraitConstraintsDiag } ;
1
4
use crate :: LateContext ;
2
5
use crate :: LateLintPass ;
3
6
use crate :: LintContext ;
4
- use rustc_errors:: fluent;
5
7
use rustc_hir as hir;
6
8
use rustc_span:: symbol:: sym;
7
9
@@ -101,17 +103,13 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
101
103
if trait_predicate. trait_ref . self_ty ( ) . is_impl_trait ( ) {
102
104
continue ;
103
105
}
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
106
108
} ;
107
- cx. struct_span_lint (
109
+ cx. emit_spanned_lint (
108
110
DROP_BOUNDS ,
109
111
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 } ,
115
113
) ;
116
114
}
117
115
}
@@ -123,12 +121,11 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
123
121
} ;
124
122
for bound in & bounds[ ..] {
125
123
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 } ) ;
132
129
}
133
130
}
134
131
}
0 commit comments