From dbbdb56d9ea2a77e944d0789eedac020b334f404 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Tue, 3 Nov 2026 00:12:20 +0100 Subject: [PATCH] make the `no_implicit_prelude` not suppress tool attributes --- compiler/rustc_resolve/src/ident.rs | 2 +- tests/ui/tool-attributes/no_implicit_prelude.rs | 4 ++-- tests/ui/tool-attributes/no_implicit_prelude.stderr | 9 +-------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 6b460195b9b5b..25b1ad5e9d01c 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -161,7 +161,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { Scope::ExternPreludeItems | Scope::ExternPreludeFlags => { use_prelude || module_and_extern_prelude || extern_prelude } - Scope::ToolAttributePrelude => use_prelude, + Scope::ToolAttributePrelude => true, Scope::StdLibPrelude => use_prelude || ns == MacroNS, Scope::BuiltinTypes => true, }; diff --git a/tests/ui/tool-attributes/no_implicit_prelude.rs b/tests/ui/tool-attributes/no_implicit_prelude.rs index 7b06ea30d73f6..29a2372acd707 100644 --- a/tests/ui/tool-attributes/no_implicit_prelude.rs +++ b/tests/ui/tool-attributes/no_implicit_prelude.rs @@ -17,8 +17,8 @@ mod test2 { pub use ::std::derive as format_args; } - #[rustfmt::skip] - //~^ ERROR cannot find module or crate `rustfmt` in this scope + #[my_tool::attr] // Unaffected by the `no_implicit_prelude` attribute + #[rustfmt::skip] // Unaffected by the `no_implicit_prelude` attribute #[clippy::format_args(Debug)] //~^ ERROR attribute macro `clippy::format_args` is ambiguous struct Foo; diff --git a/tests/ui/tool-attributes/no_implicit_prelude.stderr b/tests/ui/tool-attributes/no_implicit_prelude.stderr index 64ef7891c42cb..8aa6407ac3ed0 100644 --- a/tests/ui/tool-attributes/no_implicit_prelude.stderr +++ b/tests/ui/tool-attributes/no_implicit_prelude.stderr @@ -16,12 +16,5 @@ LL | #[clippy::format_args(Debug)] = note: ambiguous because of a name conflict with a tool namespace = note: `clippy` could refer to a tool namespace -error[E0433]: cannot find module or crate `rustfmt` in this scope - --> $DIR/no_implicit_prelude.rs:20:7 - | -LL | #[rustfmt::skip] - | ^^^^^^^ use of unresolved module or unlinked crate `rustfmt` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0433`.