diff options
| author | dswij <dharmasw@outlook.com> | 2025-01-10 12:33:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-10 12:33:19 +0000 |
| commit | 716a3a477866c3b7070b3f4d0dc4677bcadb4d1e (patch) | |
| tree | b281830731bdfc81419fae9ad7fee33fe0789742 | |
| parent | 5c2601af15c6cba486c5d00a28dc31d8915d26eb (diff) | |
| parent | d8301d762f423b2a08f67319a4178dc2c45bf934 (diff) | |
| download | rust-716a3a477866c3b7070b3f4d0dc4677bcadb4d1e.tar.gz rust-716a3a477866c3b7070b3f4d0dc4677bcadb4d1e.zip | |
Do not intersect spans coming from different contexts (#13942)
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. This is the only instance I could identify where placeholders were used instead of the real snippet when running the CI lintcheck. Moreover, the placeholders were not even used, as they snippet was obtained prematurely. Found in the context of #13941 changelog: none
| -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); |
