Skip to content

Make lint ambiguous_glob_imports deny-by-default and report-in-deps #143011

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

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4343,11 +4343,12 @@ declare_lint! {
///
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub AMBIGUOUS_GLOB_IMPORTS,
Warn,
Deny,
"detects certain glob imports that require reporting an ambiguity error",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseError,
reference: "issue #114095 <https://github.com/rust-lang/rust/issues/114095>",
report_in_deps: true,
};
}

Expand Down
3 changes: 1 addition & 2 deletions tests/ui/imports/ambiguous-1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ check-pass
// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883

macro_rules! m {
Expand All @@ -25,6 +24,6 @@ pub use openssl::*;

fn main() {
id();
//~^ WARNING `id` is ambiguous
//~^ ERROR `id` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}
38 changes: 31 additions & 7 deletions tests/ui/imports/ambiguous-1.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: ambiguous glob re-exports
--> $DIR/ambiguous-1.rs:11:13
--> $DIR/ambiguous-1.rs:10:13
|
LL | pub use self::evp::*;
| ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here
Expand All @@ -9,8 +9,8 @@ LL | pub use self::handwritten::*;
|
= note: `#[warn(ambiguous_glob_reexports)]` on by default

warning: `id` is ambiguous
--> $DIR/ambiguous-1.rs:27:5
error: `id` is ambiguous
--> $DIR/ambiguous-1.rs:26:5
|
LL | id();
| ^^ ambiguous name
Expand All @@ -19,18 +19,42 @@ LL | id();
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `id` could refer to the function imported here
--> $DIR/ambiguous-1.rs:11:13
--> $DIR/ambiguous-1.rs:10:13
|
LL | pub use self::evp::*;
| ^^^^^^^^^^^^
= help: consider adding an explicit import of `id` to disambiguate
note: `id` could also refer to the function imported here
--> $DIR/ambiguous-1.rs:13:13
--> $DIR/ambiguous-1.rs:12:13
|
LL | pub use self::handwritten::*;
| ^^^^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `id` to disambiguate
= note: `#[warn(ambiguous_glob_imports)]` on by default
= note: `#[deny(ambiguous_glob_imports)]` on by default

warning: 2 warnings emitted
error: aborting due to 1 previous error; 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
error: `id` is ambiguous
--> $DIR/ambiguous-1.rs:26:5
|
LL | id();
| ^^ ambiguous name
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `id` could refer to the function imported here
--> $DIR/ambiguous-1.rs:10:13
|
LL | pub use self::evp::*;
| ^^^^^^^^^^^^
= help: consider adding an explicit import of `id` to disambiguate
note: `id` could also refer to the function imported here
--> $DIR/ambiguous-1.rs:12:13
|
LL | pub use self::handwritten::*;
| ^^^^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `id` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` on by default

3 changes: 1 addition & 2 deletions tests/ui/imports/ambiguous-10.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ check-pass
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296

mod a {
Expand All @@ -14,6 +13,6 @@ mod b {
use crate::a::*;
use crate::b::*;
fn c(_: Token) {}
//~^ WARNING `Token` is ambiguous
//~^ ERROR `Token` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
fn main() { }
36 changes: 30 additions & 6 deletions tests/ui/imports/ambiguous-10.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: `Token` is ambiguous
--> $DIR/ambiguous-10.rs:16:9
error: `Token` is ambiguous
--> $DIR/ambiguous-10.rs:15:9
|
LL | fn c(_: Token) {}
| ^^^^^ ambiguous name
Expand All @@ -8,18 +8,42 @@ LL | fn c(_: Token) {}
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `Token` could refer to the enum imported here
--> $DIR/ambiguous-10.rs:14:5
--> $DIR/ambiguous-10.rs:13:5
|
LL | use crate::a::*;
| ^^^^^^^^^^^
= help: consider adding an explicit import of `Token` to disambiguate
note: `Token` could also refer to the enum imported here
--> $DIR/ambiguous-10.rs:15:5
--> $DIR/ambiguous-10.rs:14:5
|
LL | use crate::b::*;
| ^^^^^^^^^^^
= help: consider adding an explicit import of `Token` to disambiguate
= note: `#[warn(ambiguous_glob_imports)]` on by default
= note: `#[deny(ambiguous_glob_imports)]` on by default

error: aborting due to 1 previous error

warning: 1 warning emitted
Future incompatibility report: Future breakage diagnostic:
error: `Token` is ambiguous
--> $DIR/ambiguous-10.rs:15:9
|
LL | fn c(_: Token) {}
| ^^^^^ ambiguous name
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `Token` could refer to the enum imported here
--> $DIR/ambiguous-10.rs:13:5
|
LL | use crate::a::*;
| ^^^^^^^^^^^
= help: consider adding an explicit import of `Token` to disambiguate
note: `Token` could also refer to the enum imported here
--> $DIR/ambiguous-10.rs:14:5
|
LL | use crate::b::*;
| ^^^^^^^^^^^
= help: consider adding an explicit import of `Token` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` on by default

3 changes: 1 addition & 2 deletions tests/ui/imports/ambiguous-12.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ check-pass
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296

macro_rules! m {
Expand All @@ -20,6 +19,6 @@ use crate::public::*;

fn main() {
b();
//~^ WARNING `b` is ambiguous
//~^ ERROR `b` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}
36 changes: 30 additions & 6 deletions tests/ui/imports/ambiguous-12.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: `b` is ambiguous
--> $DIR/ambiguous-12.rs:22:5
error: `b` is ambiguous
--> $DIR/ambiguous-12.rs:21:5
|
LL | b();
| ^ ambiguous name
Expand All @@ -8,18 +8,42 @@ LL | b();
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `b` could refer to the function imported here
--> $DIR/ambiguous-12.rs:18:5
--> $DIR/ambiguous-12.rs:17:5
|
LL | use crate::ciphertext::*;
| ^^^^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `b` to disambiguate
note: `b` could also refer to the function imported here
--> $DIR/ambiguous-12.rs:19:5
--> $DIR/ambiguous-12.rs:18:5
|
LL | use crate::public::*;
| ^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `b` to disambiguate
= note: `#[warn(ambiguous_glob_imports)]` on by default
= note: `#[deny(ambiguous_glob_imports)]` on by default

error: aborting due to 1 previous error

warning: 1 warning emitted
Future incompatibility report: Future breakage diagnostic:
error: `b` is ambiguous
--> $DIR/ambiguous-12.rs:21:5
|
LL | b();
| ^ ambiguous name
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `b` could refer to the function imported here
--> $DIR/ambiguous-12.rs:17:5
|
LL | use crate::ciphertext::*;
| ^^^^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `b` to disambiguate
note: `b` could also refer to the function imported here
--> $DIR/ambiguous-12.rs:18:5
|
LL | use crate::public::*;
| ^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `b` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` on by default

3 changes: 1 addition & 2 deletions tests/ui/imports/ambiguous-13.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ check-pass
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296

pub mod object {
Expand All @@ -17,6 +16,6 @@ use crate::object::*;
use crate::content::*;

fn a(_: Rect) {}
//~^ WARNING `Rect` is ambiguous
//~^ ERROR `Rect` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
fn main() { }
36 changes: 30 additions & 6 deletions tests/ui/imports/ambiguous-13.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: `Rect` is ambiguous
--> $DIR/ambiguous-13.rs:19:9
error: `Rect` is ambiguous
--> $DIR/ambiguous-13.rs:18:9
|
LL | fn a(_: Rect) {}
| ^^^^ ambiguous name
Expand All @@ -8,18 +8,42 @@ LL | fn a(_: Rect) {}
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `Rect` could refer to the struct imported here
--> $DIR/ambiguous-13.rs:16:5
--> $DIR/ambiguous-13.rs:15:5
|
LL | use crate::object::*;
| ^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `Rect` to disambiguate
note: `Rect` could also refer to the struct imported here
--> $DIR/ambiguous-13.rs:17:5
--> $DIR/ambiguous-13.rs:16:5
|
LL | use crate::content::*;
| ^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `Rect` to disambiguate
= note: `#[warn(ambiguous_glob_imports)]` on by default
= note: `#[deny(ambiguous_glob_imports)]` on by default

error: aborting due to 1 previous error

warning: 1 warning emitted
Future incompatibility report: Future breakage diagnostic:
error: `Rect` is ambiguous
--> $DIR/ambiguous-13.rs:18:9
|
LL | fn a(_: Rect) {}
| ^^^^ ambiguous name
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `Rect` could refer to the struct imported here
--> $DIR/ambiguous-13.rs:15:5
|
LL | use crate::object::*;
| ^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `Rect` to disambiguate
note: `Rect` could also refer to the struct imported here
--> $DIR/ambiguous-13.rs:16:5
|
LL | use crate::content::*;
| ^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `Rect` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` on by default

3 changes: 1 addition & 2 deletions tests/ui/imports/ambiguous-14.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ check-pass
// https://github.com/rust-lang/rust/issues/98467

mod a {
Expand All @@ -21,6 +20,6 @@ mod g {

fn main() {
g::foo();
//~^ WARNING `foo` is ambiguous
//~^ ERROR `foo` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}
36 changes: 30 additions & 6 deletions tests/ui/imports/ambiguous-14.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: `foo` is ambiguous
--> $DIR/ambiguous-14.rs:23:8
error: `foo` is ambiguous
--> $DIR/ambiguous-14.rs:22:8
|
LL | g::foo();
| ^^^ ambiguous name
Expand All @@ -8,18 +8,42 @@ LL | g::foo();
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `foo` could refer to the function imported here
--> $DIR/ambiguous-14.rs:13:13
--> $DIR/ambiguous-14.rs:12:13
|
LL | pub use a::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
note: `foo` could also refer to the function imported here
--> $DIR/ambiguous-14.rs:14:13
--> $DIR/ambiguous-14.rs:13:13
|
LL | pub use b::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
= note: `#[warn(ambiguous_glob_imports)]` on by default
= note: `#[deny(ambiguous_glob_imports)]` on by default

error: aborting due to 1 previous error

warning: 1 warning emitted
Future incompatibility report: Future breakage diagnostic:
error: `foo` is ambiguous
--> $DIR/ambiguous-14.rs:22:8
|
LL | g::foo();
| ^^^ ambiguous name
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `foo` could refer to the function imported here
--> $DIR/ambiguous-14.rs:12:13
|
LL | pub use a::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
note: `foo` could also refer to the function imported here
--> $DIR/ambiguous-14.rs:13:13
|
LL | pub use b::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` on by default

3 changes: 1 addition & 2 deletions tests/ui/imports/ambiguous-15.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ check-pass
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152

mod t2 {
Expand All @@ -21,7 +20,7 @@ mod t3 {

use self::t3::*;
fn a<E: Error>(_: E) {}
//~^ WARNING `Error` is ambiguous
//~^ ERROR `Error` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

fn main() {}
Loading
Loading