@@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
120
120
let arg_ty = cx. typeck_results ( ) . expr_ty ( arg) ;
121
121
let is_copy = is_copy ( cx, arg_ty) ;
122
122
let drop_is_single_call_in_arm = is_single_call_in_arm ( cx, arg, expr) ;
123
- let ( lint, msg) = match fn_name {
123
+ let ( lint, msg, note_span ) = match fn_name {
124
124
// early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, forgetting_copy_types
125
125
sym:: mem_drop if arg_ty. is_ref ( ) && !drop_is_single_call_in_arm => return ,
126
126
sym:: mem_forget if arg_ty. is_ref ( ) => return ,
@@ -144,20 +144,24 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
144
144
|| drop_is_single_call_in_arm
145
145
) =>
146
146
{
147
- ( DROP_NON_DROP , DROP_NON_DROP_SUMMARY . into ( ) )
147
+ ( DROP_NON_DROP , DROP_NON_DROP_SUMMARY . into ( ) , Some ( arg . span ) )
148
148
} ,
149
149
sym:: mem_forget => {
150
150
if arg_ty. needs_drop ( cx. tcx , cx. param_env ) {
151
- ( MEM_FORGET , Cow :: Owned ( format ! (
152
- "usage of `mem::forget` on {}" ,
153
- if arg_ty. ty_adt_def( ) . map_or( false , |def| def. has_dtor( cx. tcx) ) {
154
- "`Drop` type"
155
- } else {
156
- "type with `Drop` fields"
157
- }
158
- ) ) )
151
+ (
152
+ MEM_FORGET ,
153
+ Cow :: Owned ( format ! (
154
+ "usage of `mem::forget` on {}" ,
155
+ if arg_ty. ty_adt_def( ) . map_or( false , |def| def. has_dtor( cx. tcx) ) {
156
+ "`Drop` type"
157
+ } else {
158
+ "type with `Drop` fields"
159
+ }
160
+ ) ) ,
161
+ None ,
162
+ )
159
163
} else {
160
- ( FORGET_NON_DROP , FORGET_NON_DROP_SUMMARY . into ( ) )
164
+ ( FORGET_NON_DROP , FORGET_NON_DROP_SUMMARY . into ( ) , Some ( arg . span ) )
161
165
}
162
166
}
163
167
_ => return ,
@@ -167,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
167
171
lint,
168
172
expr. span ,
169
173
& msg,
170
- Some ( arg . span ) ,
174
+ note_span ,
171
175
& format ! ( "argument has type `{arg_ty}`" ) ,
172
176
) ;
173
177
}
0 commit comments