@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
33use clippy_utils:: higher:: has_let_expr;
44use clippy_utils:: msrvs:: { self , Msrv } ;
55use clippy_utils:: res:: MaybeDef ;
6- use clippy_utils:: source:: SpanRangeExt ;
6+ use clippy_utils:: source:: { SpanRangeExt , snippet_with_context } ;
77use clippy_utils:: sugg:: Sugg ;
88use clippy_utils:: ty:: implements_trait;
99use clippy_utils:: { eq_expr_value, sym} ;
@@ -415,19 +415,20 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: Msrv, expr: &Expr<'_>) -> Optio
415415 BinOpKind :: Ge => Some ( " < " ) ,
416416 _ => None ,
417417 }
418- . and_then ( |op| {
419- let lhs_snippet = lhs. span . get_source_text ( cx) ?;
420- let rhs_snippet = rhs. span . get_source_text ( cx) ?;
418+ . map ( |op| {
419+ let mut app = Applicability :: MachineApplicable ;
420+ let ( lhs_snippet, _) = snippet_with_context ( cx, lhs. span , SyntaxContext :: root ( ) , "" , & mut app) ;
421+ let ( rhs_snippet, _) = snippet_with_context ( cx, rhs. span , SyntaxContext :: root ( ) , "" , & mut app) ;
421422
422423 if !( lhs_snippet. starts_with ( '(' ) && lhs_snippet. ends_with ( ')' ) )
423424 && let ( ExprKind :: Cast ( ..) , BinOpKind :: Ge ) = ( & lhs. kind , binop. node )
424425 {
425426 // e.g. `(a as u64) < b`. Without the parens the `<` is
426427 // interpreted as a start of generic arguments for `u64`
427- return Some ( format ! ( "({lhs_snippet}){op}{rhs_snippet}" ) ) ;
428+ return format ! ( "({lhs_snippet}){op}{rhs_snippet}" ) ;
428429 }
429430
430- Some ( format ! ( "{lhs_snippet}{op}{rhs_snippet}" ) )
431+ format ! ( "{lhs_snippet}{op}{rhs_snippet}" )
431432 } )
432433 } ,
433434 ExprKind :: MethodCall ( path, receiver, args, _) => {
0 commit comments