diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2025-01-04 18:43:32 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2025-01-10 10:02:27 +0100 |
| commit | d8301d762f423b2a08f67319a4178dc2c45bf934 (patch) | |
| tree | 3b911958c4f5b20650cbc76ebc52ee808b964c7b | |
| parent | 197d58d59171acd4a903f04ce1a4be7e299b3b46 (diff) | |
| download | rust-d8301d762f423b2a08f67319a4178dc2c45bf934.tar.gz rust-d8301d762f423b2a08f67319a4178dc2c45bf934.zip | |
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.
| -rw-r--r-- | clippy_lints/src/no_mangle_with_rust_abi.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clippy_lints/src/no_mangle_with_rust_abi.rs b/clippy_lints/src/no_mangle_with_rust_abi.rs index 9ee4e493277..2e2916c957d 100644 --- a/clippy_lints/src/no_mangle_with_rust_abi.rs +++ b/clippy_lints/src/no_mangle_with_rust_abi.rs @@ -37,7 +37,9 @@ declare_lint_pass!(NoMangleWithRustAbi => [NO_MANGLE_WITH_RUST_ABI]); impl<'tcx> LateLintPass<'tcx> for NoMangleWithRustAbi { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) { - if let ItemKind::Fn { sig: fn_sig, .. } = &item.kind { + if let ItemKind::Fn { sig: fn_sig, .. } = &item.kind + && !item.span.from_expansion() + { let attrs = cx.tcx.hir().attrs(item.hir_id()); let mut app = Applicability::MaybeIncorrect; let fn_snippet = snippet_with_applicability(cx, fn_sig.span.with_hi(item.ident.span.lo()), "..", &mut app); |
