@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22use clippy_utils:: higher:: IfLetOrMatch ;
33use clippy_utils:: msrvs:: { self , Msrv } ;
44use clippy_utils:: peel_blocks;
5- use clippy_utils:: source:: { snippet , snippet_with_macro_callsite } ;
5+ use clippy_utils:: source:: snippet_with_context ;
66use clippy_utils:: ty:: is_type_diagnostic_item;
77use clippy_utils:: visitors:: { for_each_expr, Descend } ;
88use if_chain:: if_chain;
@@ -141,16 +141,10 @@ fn emit_manual_let_else(cx: &LateContext<'_>, span: Span, expr: &Expr<'_>, pat:
141141 // * unused binding collision detection with existing ones
142142 // * putting patterns with at the top level | inside ()
143143 // for this to be machine applicable.
144- let app = Applicability :: HasPlaceholders ;
145-
146- let snippet_fn = if span. from_expansion ( ) {
147- snippet
148- } else {
149- snippet_with_macro_callsite
150- } ;
151- let sn_pat = snippet_fn ( cx, pat. span , "" ) ;
152- let sn_expr = snippet_fn ( cx, expr. span , "" ) ;
153- let sn_else = snippet_fn ( cx, else_body. span , "" ) ;
144+ let mut app = Applicability :: HasPlaceholders ;
145+ let ( sn_pat, _) = snippet_with_context ( cx, pat. span , span. ctxt ( ) , "" , & mut app) ;
146+ let ( sn_expr, _) = snippet_with_context ( cx, expr. span , span. ctxt ( ) , "" , & mut app) ;
147+ let ( sn_else, _) = snippet_with_context ( cx, else_body. span , span. ctxt ( ) , "" , & mut app) ;
154148
155149 let else_bl = if matches ! ( else_body. kind, ExprKind :: Block ( ..) ) {
156150 sn_else. into_owned ( )
0 commit comments