@@ -183,7 +183,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
183
183
self . output . push_str ( & str)
184
184
} else {
185
185
self . output . push ( '!' ) ;
186
- let snip = snip ( self . cx , terminal) ?;
186
+ let snip = snippet_opt ( self . cx , terminal. span ) ?;
187
187
self . output . push_str ( & snip) ;
188
188
}
189
189
} ,
@@ -215,18 +215,14 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
215
215
}
216
216
} ,
217
217
& Term ( n) => {
218
- let snip = snip ( self . cx , self . terminals [ n as usize ] ) ?;
218
+ let snip = snippet_opt ( self . cx , self . terminals [ n as usize ] . span ) ?;
219
219
self . output . push_str ( & snip) ;
220
220
} ,
221
221
}
222
222
Some ( ( ) )
223
223
}
224
224
}
225
225
226
- fn snip ( cx : & LateContext < ' _ , ' _ > , e : & Expr ) -> Option < String > {
227
- snippet_opt ( cx, e. span )
228
- }
229
-
230
226
fn simplify_not ( cx : & LateContext < ' _ , ' _ > , expr : & Expr ) -> Option < String > {
231
227
match & expr. node {
232
228
ExprKind :: Binary ( binop, lhs, rhs) => {
@@ -243,7 +239,14 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<String> {
243
239
BinOpKind :: Ge => Some ( " < " ) ,
244
240
_ => None ,
245
241
}
246
- . and_then ( |op| Some ( format ! ( "{}{}{}" , snip( cx, lhs) ?, op, snip( cx, rhs) ?) ) )
242
+ . and_then ( |op| {
243
+ Some ( format ! (
244
+ "{}{}{}" ,
245
+ snippet_opt( cx, lhs. span) ?,
246
+ op,
247
+ snippet_opt( cx, rhs. span) ?
248
+ ) )
249
+ } )
247
250
} ,
248
251
ExprKind :: MethodCall ( path, _, args) if args. len ( ) == 1 => {
249
252
let type_of_receiver = cx. tables . expr_ty ( & args[ 0 ] ) ;
@@ -255,7 +258,7 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<String> {
255
258
. cloned ( )
256
259
. flat_map ( |( a, b) | vec ! [ ( a, b) , ( b, a) ] )
257
260
. find ( |& ( a, _) | a == path. ident . name . as_str ( ) )
258
- . and_then ( |( _, neg_method) | Some ( format ! ( "{}.{}()" , snip ( cx, & args[ 0 ] ) ?, neg_method) ) )
261
+ . and_then ( |( _, neg_method) | Some ( format ! ( "{}.{}()" , snippet_opt ( cx, args[ 0 ] . span ) ?, neg_method) ) )
259
262
} ,
260
263
_ => None ,
261
264
}
0 commit comments