From 3443c7dcfc666088e8ccfd978790e3dad0f5cc53 Mon Sep 17 00:00:00 2001 From: Qai Juang <237468078+qaijuang@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:25:07 -0400 Subject: [PATCH 1/2] Rewrite use-statement-duplicate-check-7663 test --- ...licate-check-7663.explicit_explicit.stderr | 17 +++++++ ...ment-duplicate-check-7663.glob_glob.stderr | 23 +++++++++ .../use-statement-duplicate-check-7663.rs | 51 ++++++++++++------- 3 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 tests/ui/modules/use-statement-duplicate-check-7663.explicit_explicit.stderr create mode 100644 tests/ui/modules/use-statement-duplicate-check-7663.glob_glob.stderr diff --git a/tests/ui/modules/use-statement-duplicate-check-7663.explicit_explicit.stderr b/tests/ui/modules/use-statement-duplicate-check-7663.explicit_explicit.stderr new file mode 100644 index 0000000000000..bf87fff596221 --- /dev/null +++ b/tests/ui/modules/use-statement-duplicate-check-7663.explicit_explicit.stderr @@ -0,0 +1,17 @@ +error[E0252]: the name `p` is defined multiple times + --> $DIR/use-statement-duplicate-check-7663.rs:34:9 + | +LL | use crate::foo::p; + | ------------- previous import of the value `p` here +LL | use crate::bar::p; + | ^^^^^^^^^^^^^ `p` reimported here + | + = note: `p` must be defined only once in the value namespace of this module +help: you can use `as` to change the binding name of the import + | +LL | use crate::bar::p as other_p; + | ++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0252`. diff --git a/tests/ui/modules/use-statement-duplicate-check-7663.glob_glob.stderr b/tests/ui/modules/use-statement-duplicate-check-7663.glob_glob.stderr new file mode 100644 index 0000000000000..58ee83595d0e4 --- /dev/null +++ b/tests/ui/modules/use-statement-duplicate-check-7663.glob_glob.stderr @@ -0,0 +1,23 @@ +error[E0659]: `p` is ambiguous + --> $DIR/use-statement-duplicate-check-7663.rs:27:9 + | +LL | p() + | ^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `p` could refer to the function imported here + --> $DIR/use-statement-duplicate-check-7663.rs:23:9 + | +LL | use crate::bar::*; + | ^^^^^^^^^^^^^ + = help: consider adding an explicit import of `p` to disambiguate +note: `p` could also refer to the function imported here + --> $DIR/use-statement-duplicate-check-7663.rs:24:9 + | +LL | use crate::foo::*; + | ^^^^^^^^^^^^^ + = help: consider adding an explicit import of `p` to disambiguate + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/modules/use-statement-duplicate-check-7663.rs b/tests/ui/modules/use-statement-duplicate-check-7663.rs index 872806594fc40..9ecff578e4b44 100644 --- a/tests/ui/modules/use-statement-duplicate-check-7663.rs +++ b/tests/ui/modules/use-statement-duplicate-check-7663.rs @@ -1,33 +1,48 @@ // https://github.com/rust-lang/rust/issues/7663 -//@ run-pass +//@ revisions: glob_glob explicit_explicit glob_explicit +//@[glob_glob] check-fail +//@[explicit_explicit] check-fail +//@[glob_explicit] check-pass #![allow(unused_imports, dead_code)] -mod test1 { +mod foo { + pub fn p() -> &'static str { + "foo" + } +} - mod foo { pub fn p() -> isize { 1 } } - mod bar { pub fn p() -> isize { 2 } } +mod bar { + pub fn p() -> usize { + 2 + } +} - pub mod baz { - use crate::test1::bar::p; +#[cfg(glob_glob)] +mod case { + use crate::bar::*; + use crate::foo::*; - pub fn my_main() { assert_eq!(p(), 2); } + fn check() -> usize { + p() //[glob_glob]~ ERROR `p` is ambiguous } } -mod test2 { - - mod foo { pub fn p() -> isize { 1 } } - mod bar { pub fn p() -> isize { 2 } } +#[cfg(explicit_explicit)] +mod case { + use crate::foo::p; + use crate::bar::p; + //[explicit_explicit]~^ ERROR the name `p` is defined multiple times +} - pub mod baz { - use crate::test2::bar::p; +#[cfg(glob_explicit)] +mod case { + use crate::foo::*; + use crate::bar::p; - pub fn my_main() { assert_eq!(p(), 2); } + fn check() -> usize { + p() } } -fn main() { - test1::baz::my_main(); - test2::baz::my_main(); -} +fn main() {} From 9ea80640803d2d0653787fb9f71042b9ba586e90 Mon Sep 17 00:00:00 2001 From: Qai Juang <237468078+qaijuang@users.noreply.github.com> Date: Tue, 21 Apr 2026 16:00:35 -0400 Subject: [PATCH 2/2] Clarify regression test comment --- tests/ui/modules/use-statement-duplicate-check-7663.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/modules/use-statement-duplicate-check-7663.rs b/tests/ui/modules/use-statement-duplicate-check-7663.rs index 9ecff578e4b44..ede38b4284b02 100644 --- a/tests/ui/modules/use-statement-duplicate-check-7663.rs +++ b/tests/ui/modules/use-statement-duplicate-check-7663.rs @@ -1,4 +1,4 @@ -// https://github.com/rust-lang/rust/issues/7663 +//! Regression test for #7663. //@ revisions: glob_glob explicit_explicit glob_explicit //@[glob_glob] check-fail //@[explicit_explicit] check-fail