Skip to content

Commit e7d8d34

Browse files
committed
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 rust-lang/rust#144131 splits module scope into two scopes for globs and non-globs, but simpler.
2 parents cf42ac6 + cb3dedc commit e7d8d34

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tests/ui/crashes/ice-6255.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macro_rules! define_other_core {
99
}
1010

1111
fn main() {
12-
core::panic!();
12+
core::panic!(); //~ ERROR: `core` is ambiguous
1313
}
1414

1515
define_other_core!();

tests/ui/crashes/ice-6255.stderr

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,25 @@ LL | define_other_core!();
99
|
1010
= note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

12-
error: aborting due to 1 previous error
12+
error[E0659]: `core` is ambiguous
13+
--> tests/ui/crashes/ice-6255.rs:12:5
14+
|
15+
LL | core::panic!();
16+
| ^^^^ ambiguous name
17+
|
18+
= 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
19+
= note: `core` could refer to a built-in crate
20+
note: `core` could also refer to the crate imported here
21+
--> tests/ui/crashes/ice-6255.rs:6:9
22+
|
23+
LL | extern crate std as core;
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
25+
...
26+
LL | define_other_core!();
27+
| -------------------- in this macro invocation
28+
= help: use `crate::core` to refer to this crate unambiguously
29+
= note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
30+
31+
error: aborting due to 2 previous errors
1332

33+
For more information about this error, try `rustc --explain E0659`.

0 commit comments

Comments
 (0)