about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-08-13 22:52:17 +0000
committerbors <bors@rust-lang.org>2025-08-13 22:52:17 +0000
commit8e7795415acaa9471b5eeb2301915d6996d289ec (patch)
tree0cc05793488d656154d1010c2f3d7d84ceb8b608 /src
parent3672a55b7cfd0a12e7097197b6242872473ffaa7 (diff)
parent9aa6cb5e56bc1987974bfa176e68281edd56ca8d (diff)
downloadrust-8e7795415acaa9471b5eeb2301915d6996d289ec.tar.gz
rust-8e7795415acaa9471b5eeb2301915d6996d289ec.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6255.rs2
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6255.stderr22
2 files changed, 22 insertions, 2 deletions
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6255.rs b/src/tools/clippy/tests/ui/crashes/ice-6255.rs
index ef1e01f80ef..5f31696c791 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-6255.rs
+++ b/src/tools/clippy/tests/ui/crashes/ice-6255.rs
@@ -9,7 +9,7 @@ macro_rules! define_other_core {
 }
 
 fn main() {
-    core::panic!();
+    core::panic!(); //~ ERROR: `core` is ambiguous
 }
 
 define_other_core!();
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6255.stderr b/src/tools/clippy/tests/ui/crashes/ice-6255.stderr
index 738e9d1bd5c..420e4af936f 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-6255.stderr
+++ b/src/tools/clippy/tests/ui/crashes/ice-6255.stderr
@@ -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`.