about summary refs log tree commit diff
diff options
context:
space:
mode:
authordswij <dswijj@gmail.com>2022-11-30 14:50:13 +0800
committerdswij <dswijj@gmail.com>2022-11-30 14:50:13 +0800
commitc502dee41ec38e6e0096abaa50a48e792e4c9d40 (patch)
tree1b0fb8e69a58d3953477732074ec8766577d1555
parenta4b53c9c14705475b6e9041b56c441c981e86423 (diff)
downloadrust-c502dee41ec38e6e0096abaa50a48e792e4c9d40.tar.gz
rust-c502dee41ec38e6e0096abaa50a48e792e4c9d40.zip
Use `snippet_with_context` instead of `_with_macro_callsite`
-rw-r--r--clippy_lints/src/manual_let_else.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/clippy_lints/src/manual_let_else.rs b/clippy_lints/src/manual_let_else.rs
index 91f0dc2a717..874d36ca9f4 100644
--- a/clippy_lints/src/manual_let_else.rs
+++ b/clippy_lints/src/manual_let_else.rs
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
 use clippy_utils::higher::IfLetOrMatch;
 use clippy_utils::msrvs::{self, Msrv};
 use clippy_utils::peel_blocks;
-use clippy_utils::source::{snippet, snippet_with_macro_callsite};
+use clippy_utils::source::snippet_with_context;
 use clippy_utils::ty::is_type_diagnostic_item;
 use clippy_utils::visitors::{for_each_expr, Descend};
 use if_chain::if_chain;
@@ -141,16 +141,10 @@ fn emit_manual_let_else(cx: &LateContext<'_>, span: Span, expr: &Expr<'_>, pat:
             // * unused binding collision detection with existing ones
             // * putting patterns with at the top level | inside ()
             // for this to be machine applicable.
-            let app = Applicability::HasPlaceholders;
-
-            let snippet_fn = if span.from_expansion() {
-                snippet
-            } else {
-                snippet_with_macro_callsite
-            };
-            let sn_pat = snippet_fn(cx, pat.span, "");
-            let sn_expr = snippet_fn(cx, expr.span, "");
-            let sn_else = snippet_fn(cx, else_body.span, "");
+            let mut app = Applicability::HasPlaceholders;
+            let (sn_pat, _) = snippet_with_context(cx, pat.span, span.ctxt(), "", &mut app);
+            let (sn_expr, _) = snippet_with_context(cx, expr.span, span.ctxt(), "", &mut app);
+            let (sn_else, _) = snippet_with_context(cx, else_body.span, span.ctxt(), "", &mut app);
 
             let else_bl = if matches!(else_body.kind, ExprKind::Block(..)) {
                 sn_else.into_owned()