@@ -167,6 +167,7 @@ fn get_closure_suggestion<'tcx>(
167
167
next_pos : None ,
168
168
suggestion_start : String :: new ( ) ,
169
169
suggestion_end : String :: new ( ) ,
170
+ applicability : Applicability :: MachineApplicable ,
170
171
} ;
171
172
172
173
let fn_def_id = cx. tcx . hir ( ) . local_def_id ( search_arg. hir_id ) ;
@@ -188,6 +189,7 @@ struct DerefDelegate<'a, 'tcx> {
188
189
next_pos : Option < BytePos > ,
189
190
suggestion_start : String ,
190
191
suggestion_end : String ,
192
+ applicability : Applicability ,
191
193
}
192
194
193
195
impl < ' tcx > Delegate < ' tcx > for DerefDelegate < ' _ , ' tcx > {
@@ -203,9 +205,9 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
203
205
} else {
204
206
self . closure_span . until ( span)
205
207
} ;
206
- let start_snip = snippet ( self . cx , start_span, ".." ) ;
208
+ let start_snip = snippet_with_applicability ( self . cx , start_span, ".." , & mut self . applicability ) ;
207
209
let end_span = Span :: new ( span. hi ( ) , self . closure_span . hi ( ) , span. ctxt ( ) ) ;
208
- let end_snip = snippet ( self . cx , end_span, ".." ) ;
210
+ let end_snip = snippet_with_applicability ( self . cx , end_span, ".." , & mut self . applicability ) ;
209
211
210
212
if cmt. place . projections . is_empty ( ) {
211
213
// handle item without any projection, that needs an explicit borrowing
@@ -227,11 +229,14 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
227
229
} else {
228
230
self . closure_span . until ( span)
229
231
} ;
230
- let start_snip = snippet ( self . cx , start_span, ".." ) ;
232
+ let start_snip =
233
+ snippet_with_applicability ( self . cx , start_span, ".." , & mut self . applicability ) ;
231
234
232
235
self . suggestion_start . push_str ( & format ! ( "{}&{}" , start_snip, ident_str) ) ;
233
236
self . suggestion_end = end_snip. to_string ( ) ;
234
237
self . next_pos = Some ( span. hi ( ) ) ;
238
+ } else {
239
+ self . applicability = Applicability :: Unspecified ;
235
240
}
236
241
}
237
242
return ;
0 commit comments