From 8ad6af7ddfa4a5db5980f2a1a303e06478f2530f Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Fri, 15 Mar 2024 14:00:08 +0000 Subject: [PATCH] Ignore paths from expansion in `unused_qualifications` --- compiler/rustc_resolve/src/late.rs | 4 +++- tests/ui/lint/lint-qualification.fixed | 1 + tests/ui/lint/lint-qualification.rs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index d2aea0056b394..5780c8017bcf7 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -4636,7 +4636,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { } fn lint_unused_qualifications(&mut self, path: &[Segment], ns: Namespace, finalize: Finalize) { - if path.iter().any(|seg| seg.ident.span.from_expansion()) { + if finalize.path_span.from_expansion() + || path.iter().any(|seg| seg.ident.span.from_expansion()) + { return; } diff --git a/tests/ui/lint/lint-qualification.fixed b/tests/ui/lint/lint-qualification.fixed index 2b1f8b591752a..25ac7c11b12b0 100644 --- a/tests/ui/lint/lint-qualification.fixed +++ b/tests/ui/lint/lint-qualification.fixed @@ -33,6 +33,7 @@ fn main() { foo::bar(); foo::$b(); // issue #96698 $a::bar(); + $a::$b(); } } m!(foo, bar); } diff --git a/tests/ui/lint/lint-qualification.rs b/tests/ui/lint/lint-qualification.rs index 002fdbf7724a7..c1d391f1f0ced 100644 --- a/tests/ui/lint/lint-qualification.rs +++ b/tests/ui/lint/lint-qualification.rs @@ -33,6 +33,7 @@ fn main() { foo::bar(); foo::$b(); // issue #96698 $a::bar(); + $a::$b(); } } m!(foo, bar); }