resolve: Pass a normalized ident to resolve_ident_in_scope

In practice it was already normalized because `visit_scopes` normalized it
This commit is contained in:
Vadim Petrochenkov 2026-01-07 01:17:11 +03:00
parent 12007736ac
commit 888e28b41b
2 changed files with 12 additions and 23 deletions

View file

@ -433,12 +433,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
orig_ident.span.ctxt(),
derive_fallback_lint_id,
|this, scope, use_prelude, ctxt| {
let ident = Ident::new(orig_ident.name, orig_ident.span.with_ctxt(ctxt));
// The passed `ctxt` is already normalized, so avoid expensive double normalization.
let ident = Macros20NormalizedIdent(ident);
let res = match this.reborrow().resolve_ident_in_scope(
orig_ident,
ident,
ns,
scope,
use_prelude,
ctxt,
scope_set,
parent_scope,
// Shadowed decls don't need to be marked as used or non-speculatively loaded.
@ -507,11 +509,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
fn resolve_ident_in_scope<'r>(
mut self: CmResolver<'r, 'ra, 'tcx>,
orig_ident: Ident,
ident: Macros20NormalizedIdent,
ns: Namespace,
scope: Scope<'ra>,
use_prelude: UsePrelude,
ctxt: SyntaxContext,
scope_set: ScopeSet<'ra>,
parent_scope: &ParentScope<'ra>,
finalize: Option<Finalize>,
@ -519,8 +520,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
ignore_decl: Option<Decl<'ra>>,
ignore_import: Option<Import<'ra>>,
) -> Result<Decl<'ra>, ControlFlow<Determinacy, Determinacy>> {
let unnorm_ident = Ident::new(orig_ident.name, orig_ident.span.with_ctxt(ctxt));
let ident = Macros20NormalizedIdent::new(unnorm_ident);
let ret = match scope {
Scope::DeriveHelpers(expn_id) => {
if let Some(decl) = self
@ -599,11 +598,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
self.get_mut().lint_buffer.buffer_lint(
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
lint_id,
orig_ident.span,
ident.span,
errors::ProcMacroDeriveResolutionFallback {
span: orig_ident.span,
span: ident.span,
ns_descr: ns.descr(),
ident: unnorm_ident,
ident: ident.0,
},
);
}
@ -649,11 +648,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
self.get_mut().lint_buffer.buffer_lint(
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
lint_id,
orig_ident.span,
ident.span,
errors::ProcMacroDeriveResolutionFallback {
span: orig_ident.span,
span: ident.span,
ns_descr: ns.descr(),
ident: unnorm_ident,
ident: ident.0,
},
);
}
@ -699,7 +698,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let mut result = Err(Determinacy::Determined);
if let Some(prelude) = self.prelude
&& let Ok(decl) = self.reborrow().resolve_ident_in_scope_set(
unnorm_ident,
ident.0,
ScopeSet::Module(ns, prelude),
parent_scope,
None,

View file

@ -47,7 +47,6 @@ LL | #[derive(generate_mod::CheckDerive)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
error: cannot find type `OuterDerive` in this scope
--> $DIR/generate-mod.rs:18:10
@ -57,7 +56,6 @@ LL | #[derive(generate_mod::CheckDerive)]
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
error: cannot find type `FromOutside` in this scope
--> $DIR/generate-mod.rs:25:14
@ -67,7 +65,6 @@ LL | #[derive(generate_mod::CheckDerive)]
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
error: cannot find type `OuterDerive` in this scope
--> $DIR/generate-mod.rs:25:14
@ -77,7 +74,6 @@ LL | #[derive(generate_mod::CheckDerive)]
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 8 previous errors
@ -92,7 +88,6 @@ LL | #[derive(generate_mod::CheckDerive)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
Future breakage diagnostic:
error: cannot find type `OuterDerive` in this scope
@ -104,7 +99,6 @@ LL | #[derive(generate_mod::CheckDerive)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
Future breakage diagnostic:
error: cannot find type `FromOutside` in this scope
@ -116,7 +110,6 @@ LL | #[derive(generate_mod::CheckDerive)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
Future breakage diagnostic:
error: cannot find type `OuterDerive` in this scope
@ -128,7 +121,6 @@ LL | #[derive(generate_mod::CheckDerive)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: `#[deny(proc_macro_derive_resolution_fallback)]` (part of `#[deny(future_incompatible)]`) on by default
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
Future breakage diagnostic:
warning: cannot find type `FromOutside` in this scope
@ -139,7 +131,6 @@ LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info)
Future breakage diagnostic:
warning: cannot find type `OuterDeriveLint` in this scope
@ -150,5 +141,4 @@ LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info)