Skip to content

Fix glob import tests #141060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2538,7 +2538,6 @@ ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.rs
ui/issues/issue-76077-inaccesible-private-fields/issue-76077.rs
ui/issues/issue-76191.rs
ui/issues/issue-7660.rs
ui/issues/issue-7663.rs
ui/issues/issue-7673-cast-generically-implemented-trait.rs
ui/issues/issue-77218/issue-77218-2.rs
ui/issues/issue-77218/issue-77218.rs
Expand Down Expand Up @@ -3634,6 +3633,7 @@ ui/resolve/issue-6702.rs
ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs
ui/resolve/issue-70736-async-fn-no-body-def-collector.rs
ui/resolve/issue-73427.rs
ui/resolve/issue-7663.rs
ui/resolve/issue-80079.rs
ui/resolve/issue-81508.rs
ui/resolve/issue-82156.rs
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ignore::Walk;
const ENTRY_LIMIT: u32 = 901;
// FIXME: The following limits should be reduced eventually.

const ISSUES_ENTRY_LIMIT: u32 = 1623;
const ISSUES_ENTRY_LIMIT: u32 = 1622;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/issues/issue-14082.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use foo::Foo;

mod foo {
pub use d::*; // this imports d::Foo
pub use m::Foo; // this should shadow d::Foo
}
Comment on lines 7 to 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: a few things:

  1. Move this test to tests/ui/resolve/, and
  2. Rename it to sth more meaningful, like non-glob-vs-glob-reexport-precedence
  3. Add a doc comment to the test to back link to the issue, e.g. //! Regression test for #14082.


Expand All @@ -16,4 +17,6 @@ mod d {
pub struct Foo;
}

fn main() {}
fn main() {
let _: foo::Foo = m::Foo;
}
32 changes: 0 additions & 32 deletions tests/ui/issues/issue-7663.rs

This file was deleted.

38 changes: 38 additions & 0 deletions tests/ui/resolve/issue-7663.rs
Copy link
Member

@jieyouxu jieyouxu May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

  • Rename this test as sth more meaningful like import-glob-ambiguity-non-glob-collision
  • Ditto on the doc comment for a backlink.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#![allow(unused_imports, dead_code)]

mod test1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: can you rename these test modules as something more semantically meaningful, e.g.

  • test1 -> glob_vs_glob_ambiguity
  • test2 -> non_glob_vs_non_glob_name_collision

mod foo {
pub struct P;
}

mod bar {
pub struct P;
}

pub mod baz {
use test1::foo::*;
use test1::bar::*;

pub fn f() {
let _ = P; //~ ERROR `P` is ambiguous
}
}
}

mod test2 {
mod foo {
pub struct P;
}

mod bar {
pub struct P;
}

pub mod baz {
use test2::foo::P;
use test2::bar::P; //~ ERROR the name `P` is defined multiple times
}
}

fn main() {
}
38 changes: 38 additions & 0 deletions tests/ui/resolve/issue-7663.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
error[E0252]: the name `P` is defined multiple times
--> $DIR/issue-7663.rs:33:13
|
LL | use test2::foo::P;
| ------------- previous import of the type `P` here
LL | use test2::bar::P;
| ^^^^^^^^^^^^^ `P` reimported here
|
= note: `P` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
LL | use test2::bar::P as OtherP;
| +++++++++

error[E0659]: `P` is ambiguous
--> $DIR/issue-7663.rs:17:21
|
LL | let _ = P;
| ^ ambiguous name
|
= note: ambiguous because of multiple glob imports of a name in the same module
note: `P` could refer to the unit struct imported here
--> $DIR/issue-7663.rs:13:13
|
LL | use test1::foo::*;
| ^^^^^^^^^^^^^
= help: consider adding an explicit import of `P` to disambiguate
note: `P` could also refer to the unit struct imported here
--> $DIR/issue-7663.rs:14:13
|
LL | use test1::bar::*;
| ^^^^^^^^^^^^^
= help: consider adding an explicit import of `P` to disambiguate

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0252, E0659.
For more information about an error, try `rustc --explain E0252`.
Loading