Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d8301d7

Browse files
committed
Do not intersect spans coming from different contexts
The code should not attempt to obtain a snippet by capping the function signature span with its identifier span without checking that they are in the same context.
1 parent 197d58d commit d8301d7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clippy_lints/src/no_mangle_with_rust_abi.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ declare_lint_pass!(NoMangleWithRustAbi => [NO_MANGLE_WITH_RUST_ABI]);
3737

3838
impl<'tcx> LateLintPass<'tcx> for NoMangleWithRustAbi {
3939
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
40-
if let ItemKind::Fn { sig: fn_sig, .. } = &item.kind {
40+
if let ItemKind::Fn { sig: fn_sig, .. } = &item.kind
41+
&& !item.span.from_expansion()
42+
{
4143
let attrs = cx.tcx.hir().attrs(item.hir_id());
4244
let mut app = Applicability::MaybeIncorrect;
4345
let fn_snippet = snippet_with_applicability(cx, fn_sig.span.with_hi(item.ident.span.lo()), "..", &mut app);

0 commit comments

Comments
 (0)