Skip to content

Commit 716a3a4

Browse files
authored
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
2 parents 5c2601a + d8301d7 commit 716a3a4

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)