@@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
120120 let arg_ty = cx. typeck_results ( ) . expr_ty ( arg) ;
121121 let is_copy = is_copy ( cx, arg_ty) ;
122122 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 {
124124 // early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, forgetting_copy_types
125125 sym:: mem_drop if arg_ty. is_ref ( ) && !drop_is_single_call_in_arm => return ,
126126 sym:: mem_forget if arg_ty. is_ref ( ) => return ,
@@ -144,20 +144,24 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
144144 || drop_is_single_call_in_arm
145145 ) =>
146146 {
147- ( DROP_NON_DROP , DROP_NON_DROP_SUMMARY . into ( ) )
147+ ( DROP_NON_DROP , DROP_NON_DROP_SUMMARY . into ( ) , Some ( arg . span ) )
148148 } ,
149149 sym:: mem_forget => {
150150 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+ )
159163 } else {
160- ( FORGET_NON_DROP , FORGET_NON_DROP_SUMMARY . into ( ) )
164+ ( FORGET_NON_DROP , FORGET_NON_DROP_SUMMARY . into ( ) , Some ( arg . span ) )
161165 }
162166 }
163167 _ => return ,
@@ -167,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
167171 lint,
168172 expr. span ,
169173 & msg,
170- Some ( arg . span ) ,
174+ note_span ,
171175 & format ! ( "argument has type `{arg_ty}`" ) ,
172176 ) ;
173177 }
0 commit comments