@@ -164,7 +164,7 @@ fn get_closure_suggestion<'tcx>(
164
164
let mut visitor = DerefDelegate {
165
165
cx,
166
166
closure_span : search_arg. span ,
167
- next_pos : None ,
167
+ next_pos : search_arg . span . lo ( ) ,
168
168
suggestion_start : String :: new ( ) ,
169
169
suggestion_end : String :: new ( ) ,
170
170
applicability : Applicability :: MachineApplicable ,
@@ -186,7 +186,7 @@ fn get_closure_suggestion<'tcx>(
186
186
struct DerefDelegate < ' a , ' tcx > {
187
187
cx : & ' a LateContext < ' tcx > ,
188
188
closure_span : Span ,
189
- next_pos : Option < BytePos > ,
189
+ next_pos : BytePos ,
190
190
suggestion_start : String ,
191
191
suggestion_end : String ,
192
192
applicability : Applicability ,
@@ -200,11 +200,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
200
200
let map = self . cx . tcx . hir ( ) ;
201
201
let ident_str = map. name ( id) . to_string ( ) ;
202
202
let span = map. span ( cmt. hir_id ) ;
203
- let start_span = if let Some ( next_pos) = self . next_pos {
204
- Span :: new ( next_pos, span. lo ( ) , span. ctxt ( ) )
205
- } else {
206
- self . closure_span . until ( span)
207
- } ;
203
+ let start_span = Span :: new ( self . next_pos , span. lo ( ) , span. ctxt ( ) ) ;
208
204
let start_snip = snippet_with_applicability ( self . cx , start_span, ".." , & mut self . applicability ) ;
209
205
let end_span = Span :: new ( span. hi ( ) , self . closure_span . hi ( ) , span. ctxt ( ) ) ;
210
206
let end_snip = snippet_with_applicability ( self . cx , end_span, ".." , & mut self . applicability ) ;
@@ -224,17 +220,13 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
224
220
for arg in & args_to_handle {
225
221
let arg_ty_kind = self . cx . typeck_results ( ) . expr_ty ( arg) . kind ( ) ;
226
222
if matches ! ( arg_ty_kind, ty:: Ref ( _, _, Mutability :: Not ) ) {
227
- let start_span = if let Some ( next_pos) = self . next_pos {
228
- Span :: new ( next_pos, span. lo ( ) , span. ctxt ( ) )
229
- } else {
230
- self . closure_span . until ( span)
231
- } ;
223
+ let start_span = Span :: new ( self . next_pos , span. lo ( ) , span. ctxt ( ) ) ;
232
224
let start_snip =
233
225
snippet_with_applicability ( self . cx , start_span, ".." , & mut self . applicability ) ;
234
226
235
227
self . suggestion_start . push_str ( & format ! ( "{}&{}" , start_snip, ident_str) ) ;
236
228
self . suggestion_end = end_snip. to_string ( ) ;
237
- self . next_pos = Some ( span. hi ( ) ) ;
229
+ self . next_pos = span. hi ( ) ;
238
230
} else {
239
231
self . applicability = Applicability :: Unspecified ;
240
232
}
@@ -268,7 +260,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
268
260
. push_str ( & format ! ( "{}{}" , start_snip, replacement_str) ) ;
269
261
self . suggestion_end = end_snip. to_string ( ) ;
270
262
}
271
- self . next_pos = Some ( span. hi ( ) ) ;
263
+ self . next_pos = span. hi ( ) ;
272
264
}
273
265
}
274
266
0 commit comments