Skip to content

Commit c502dee

Browse files
committed
Use snippet_with_context instead of _with_macro_callsite
1 parent a4b53c9 commit c502dee

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

clippy_lints/src/manual_let_else.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::higher::IfLetOrMatch;
33
use clippy_utils::msrvs::{self, Msrv};
44
use clippy_utils::peel_blocks;
5-
use clippy_utils::source::{snippet, snippet_with_macro_callsite};
5+
use clippy_utils::source::snippet_with_context;
66
use clippy_utils::ty::is_type_diagnostic_item;
77
use clippy_utils::visitors::{for_each_expr, Descend};
88
use 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

Comments
 (0)