@@ -183,7 +183,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
183183 self . output . push_str ( & str)
184184 } else {
185185 self . output . push ( '!' ) ;
186- let snip = snip ( self . cx , terminal) ?;
186+ let snip = snippet_opt ( self . cx , terminal. span ) ?;
187187 self . output . push_str ( & snip) ;
188188 }
189189 } ,
@@ -215,18 +215,14 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
215215 }
216216 } ,
217217 & 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 ) ?;
219219 self . output . push_str ( & snip) ;
220220 } ,
221221 }
222222 Some ( ( ) )
223223 }
224224}
225225
226- fn snip ( cx : & LateContext < ' _ , ' _ > , e : & Expr ) -> Option < String > {
227- snippet_opt ( cx, e. span )
228- }
229-
230226fn simplify_not ( cx : & LateContext < ' _ , ' _ > , expr : & Expr ) -> Option < String > {
231227 match & expr. node {
232228 ExprKind :: Binary ( binop, lhs, rhs) => {
@@ -243,7 +239,14 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<String> {
243239 BinOpKind :: Ge => Some ( " < " ) ,
244240 _ => None ,
245241 }
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+ } )
247250 } ,
248251 ExprKind :: MethodCall ( path, _, args) if args. len ( ) == 1 => {
249252 let type_of_receiver = cx. tables . expr_ty ( & args[ 0 ] ) ;
@@ -255,7 +258,7 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<String> {
255258 . cloned ( )
256259 . flat_map ( |( a, b) | vec ! [ ( a, b) , ( b, a) ] )
257260 . 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) ) )
259262 } ,
260263 _ => None ,
261264 }
0 commit comments