Auto merge of #144793 - petrochenkov:extprel3, r=davidtwco

resolve: Split extern prelude into two scopes

One scope for `extern crate` items and another for `--extern` options, with the former shadowing the latter.

If in a single scope some things can overwrite other things, especially with ad hoc restrictions like `MacroExpandedExternCrateCannotShadowExternArguments`, then it's not really a single scope.
So this PR splits `Scope::ExternPrelude` into two cleaner scopes.

This is similar to how https://github.com/rust-lang/rust/pull/144131 splits module scope into two scopes for globs and non-globs, but simpler.
This commit is contained in:
bors 2025-08-13 22:52:17 +00:00
commit e7d8d34eae
2 changed files with 22 additions and 2 deletions

View file

@ -9,7 +9,7 @@ macro_rules! define_other_core {
}
fn main() {
core::panic!();
core::panic!(); //~ ERROR: `core` is ambiguous
}
define_other_core!();

View file

@ -9,5 +9,25 @@ LL | define_other_core!();
|
= note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
error[E0659]: `core` is ambiguous
--> tests/ui/crashes/ice-6255.rs:12:5
|
LL | core::panic!();
| ^^^^ ambiguous name
|
= note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
= note: `core` could refer to a built-in crate
note: `core` could also refer to the crate imported here
--> tests/ui/crashes/ice-6255.rs:6:9
|
LL | extern crate std as core;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | define_other_core!();
| -------------------- in this macro invocation
= help: use `crate::core` to refer to this crate unambiguously
= note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0659`.