Skip to content

Commit 6bcc39c

Browse files
authored
Rollup merge of #143011 - LorrensP-2158466:warn-ambiguity-into-error, r=petrochenkov
Make lint `ambiguous_glob_imports` deny-by-default and report-in-deps This pr aims to finish the second part of #114095. It converts the `ambiguous_glob_imports` lint from a warning to an error. Currently, only the lint definition and the related tests are changed, a crater run should provide us with information on whether we should go for this.
2 parents 643efda + b286bc3 commit 6bcc39c

32 files changed

+510
-116
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4343,11 +4343,12 @@ declare_lint! {
43434343
///
43444344
/// [future-incompatible]: ../index.md#future-incompatible-lints
43454345
pub AMBIGUOUS_GLOB_IMPORTS,
4346-
Warn,
4346+
Deny,
43474347
"detects certain glob imports that require reporting an ambiguity error",
43484348
@future_incompatible = FutureIncompatibleInfo {
43494349
reason: FutureIncompatibilityReason::FutureReleaseError,
43504350
reference: "issue #114095 <https://github.com/rust-lang/rust/issues/114095>",
4351+
report_in_deps: true,
43514352
};
43524353
}
43534354

tests/ui/imports/ambiguous-1.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883
33

4+
#![warn(ambiguous_glob_imports)]
5+
46
macro_rules! m {
57
() => {
68
pub fn id() {}

tests/ui/imports/ambiguous-1.stderr

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: ambiguous glob re-exports
2-
--> $DIR/ambiguous-1.rs:11:13
2+
--> $DIR/ambiguous-1.rs:13:13
33
|
44
LL | pub use self::evp::*;
55
| ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here
@@ -10,7 +10,7 @@ LL | pub use self::handwritten::*;
1010
= note: `#[warn(ambiguous_glob_reexports)]` on by default
1111

1212
warning: `id` is ambiguous
13-
--> $DIR/ambiguous-1.rs:27:5
13+
--> $DIR/ambiguous-1.rs:29:5
1414
|
1515
LL | id();
1616
| ^^ ambiguous name
@@ -19,18 +19,50 @@ LL | id();
1919
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
2020
= note: ambiguous because of multiple glob imports of a name in the same module
2121
note: `id` could refer to the function imported here
22-
--> $DIR/ambiguous-1.rs:11:13
22+
--> $DIR/ambiguous-1.rs:13:13
2323
|
2424
LL | pub use self::evp::*;
2525
| ^^^^^^^^^^^^
2626
= help: consider adding an explicit import of `id` to disambiguate
2727
note: `id` could also refer to the function imported here
28-
--> $DIR/ambiguous-1.rs:13:13
28+
--> $DIR/ambiguous-1.rs:15:13
2929
|
3030
LL | pub use self::handwritten::*;
3131
| ^^^^^^^^^^^^^^^^^^^^
3232
= help: consider adding an explicit import of `id` to disambiguate
33-
= note: `#[warn(ambiguous_glob_imports)]` on by default
33+
note: the lint level is defined here
34+
--> $DIR/ambiguous-1.rs:4:9
35+
|
36+
LL | #![warn(ambiguous_glob_imports)]
37+
| ^^^^^^^^^^^^^^^^^^^^^^
3438

3539
warning: 2 warnings emitted
3640

41+
Future incompatibility report: Future breakage diagnostic:
42+
warning: `id` is ambiguous
43+
--> $DIR/ambiguous-1.rs:29:5
44+
|
45+
LL | id();
46+
| ^^ ambiguous name
47+
|
48+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
49+
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
50+
= note: ambiguous because of multiple glob imports of a name in the same module
51+
note: `id` could refer to the function imported here
52+
--> $DIR/ambiguous-1.rs:13:13
53+
|
54+
LL | pub use self::evp::*;
55+
| ^^^^^^^^^^^^
56+
= help: consider adding an explicit import of `id` to disambiguate
57+
note: `id` could also refer to the function imported here
58+
--> $DIR/ambiguous-1.rs:15:13
59+
|
60+
LL | pub use self::handwritten::*;
61+
| ^^^^^^^^^^^^^^^^^^^^
62+
= help: consider adding an explicit import of `id` to disambiguate
63+
note: the lint level is defined here
64+
--> $DIR/ambiguous-1.rs:4:9
65+
|
66+
LL | #![warn(ambiguous_glob_imports)]
67+
| ^^^^^^^^^^^^^^^^^^^^^^
68+

tests/ui/imports/ambiguous-10.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ check-pass
21
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296
32

43
mod a {
@@ -14,6 +13,6 @@ mod b {
1413
use crate::a::*;
1514
use crate::b::*;
1615
fn c(_: Token) {}
17-
//~^ WARNING `Token` is ambiguous
16+
//~^ ERROR `Token` is ambiguous
1817
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1918
fn main() { }

tests/ui/imports/ambiguous-10.stderr

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
warning: `Token` is ambiguous
2-
--> $DIR/ambiguous-10.rs:16:9
1+
error: `Token` is ambiguous
2+
--> $DIR/ambiguous-10.rs:15:9
33
|
44
LL | fn c(_: Token) {}
55
| ^^^^^ ambiguous name
@@ -8,18 +8,42 @@ LL | fn c(_: Token) {}
88
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
99
= note: ambiguous because of multiple glob imports of a name in the same module
1010
note: `Token` could refer to the enum imported here
11-
--> $DIR/ambiguous-10.rs:14:5
11+
--> $DIR/ambiguous-10.rs:13:5
1212
|
1313
LL | use crate::a::*;
1414
| ^^^^^^^^^^^
1515
= help: consider adding an explicit import of `Token` to disambiguate
1616
note: `Token` could also refer to the enum imported here
17-
--> $DIR/ambiguous-10.rs:15:5
17+
--> $DIR/ambiguous-10.rs:14:5
1818
|
1919
LL | use crate::b::*;
2020
| ^^^^^^^^^^^
2121
= help: consider adding an explicit import of `Token` to disambiguate
22-
= note: `#[warn(ambiguous_glob_imports)]` on by default
22+
= note: `#[deny(ambiguous_glob_imports)]` on by default
23+
24+
error: aborting due to 1 previous error
2325

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

tests/ui/imports/ambiguous-12.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ check-pass
21
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296
32

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

2120
fn main() {
2221
b();
23-
//~^ WARNING `b` is ambiguous
22+
//~^ ERROR `b` is ambiguous
2423
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2524
}

tests/ui/imports/ambiguous-12.stderr

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
warning: `b` is ambiguous
2-
--> $DIR/ambiguous-12.rs:22:5
1+
error: `b` is ambiguous
2+
--> $DIR/ambiguous-12.rs:21:5
33
|
44
LL | b();
55
| ^ ambiguous name
@@ -8,18 +8,42 @@ LL | b();
88
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
99
= note: ambiguous because of multiple glob imports of a name in the same module
1010
note: `b` could refer to the function imported here
11-
--> $DIR/ambiguous-12.rs:18:5
11+
--> $DIR/ambiguous-12.rs:17:5
1212
|
1313
LL | use crate::ciphertext::*;
1414
| ^^^^^^^^^^^^^^^^^^^^
1515
= help: consider adding an explicit import of `b` to disambiguate
1616
note: `b` could also refer to the function imported here
17-
--> $DIR/ambiguous-12.rs:19:5
17+
--> $DIR/ambiguous-12.rs:18:5
1818
|
1919
LL | use crate::public::*;
2020
| ^^^^^^^^^^^^^^^^
2121
= help: consider adding an explicit import of `b` to disambiguate
22-
= note: `#[warn(ambiguous_glob_imports)]` on by default
22+
= note: `#[deny(ambiguous_glob_imports)]` on by default
23+
24+
error: aborting due to 1 previous error
2325

24-
warning: 1 warning emitted
26+
Future incompatibility report: Future breakage diagnostic:
27+
error: `b` is ambiguous
28+
--> $DIR/ambiguous-12.rs:21:5
29+
|
30+
LL | b();
31+
| ^ ambiguous name
32+
|
33+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
34+
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
35+
= note: ambiguous because of multiple glob imports of a name in the same module
36+
note: `b` could refer to the function imported here
37+
--> $DIR/ambiguous-12.rs:17:5
38+
|
39+
LL | use crate::ciphertext::*;
40+
| ^^^^^^^^^^^^^^^^^^^^
41+
= help: consider adding an explicit import of `b` to disambiguate
42+
note: `b` could also refer to the function imported here
43+
--> $DIR/ambiguous-12.rs:18:5
44+
|
45+
LL | use crate::public::*;
46+
| ^^^^^^^^^^^^^^^^
47+
= help: consider adding an explicit import of `b` to disambiguate
48+
= note: `#[deny(ambiguous_glob_imports)]` on by default
2549

tests/ui/imports/ambiguous-13.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ check-pass
21
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296
32

43
pub mod object {
@@ -17,6 +16,6 @@ use crate::object::*;
1716
use crate::content::*;
1817

1918
fn a(_: Rect) {}
20-
//~^ WARNING `Rect` is ambiguous
19+
//~^ ERROR `Rect` is ambiguous
2120
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2221
fn main() { }

tests/ui/imports/ambiguous-13.stderr

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
warning: `Rect` is ambiguous
2-
--> $DIR/ambiguous-13.rs:19:9
1+
error: `Rect` is ambiguous
2+
--> $DIR/ambiguous-13.rs:18:9
33
|
44
LL | fn a(_: Rect) {}
55
| ^^^^ ambiguous name
@@ -8,18 +8,42 @@ LL | fn a(_: Rect) {}
88
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
99
= note: ambiguous because of multiple glob imports of a name in the same module
1010
note: `Rect` could refer to the struct imported here
11-
--> $DIR/ambiguous-13.rs:16:5
11+
--> $DIR/ambiguous-13.rs:15:5
1212
|
1313
LL | use crate::object::*;
1414
| ^^^^^^^^^^^^^^^^
1515
= help: consider adding an explicit import of `Rect` to disambiguate
1616
note: `Rect` could also refer to the struct imported here
17-
--> $DIR/ambiguous-13.rs:17:5
17+
--> $DIR/ambiguous-13.rs:16:5
1818
|
1919
LL | use crate::content::*;
2020
| ^^^^^^^^^^^^^^^^^
2121
= help: consider adding an explicit import of `Rect` to disambiguate
22-
= note: `#[warn(ambiguous_glob_imports)]` on by default
22+
= note: `#[deny(ambiguous_glob_imports)]` on by default
23+
24+
error: aborting due to 1 previous error
2325

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

tests/ui/imports/ambiguous-14.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ check-pass
21
// https://github.com/rust-lang/rust/issues/98467
32

43
mod a {
@@ -21,6 +20,6 @@ mod g {
2120

2221
fn main() {
2322
g::foo();
24-
//~^ WARNING `foo` is ambiguous
23+
//~^ ERROR `foo` is ambiguous
2524
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2625
}

0 commit comments

Comments
 (0)