Skip to content

Commit 2b39fe7

Browse files
committed
Auto merge of #143011 - LorrensP-2158466:warn-ambiguity-into-error, r=<try>
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 8f21a5c + 3be0b6b commit 2b39fe7

33 files changed

+499
-125
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: 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/112743#issuecomment-1601986883
32

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

2625
fn main() {
2726
id();
28-
//~^ WARNING `id` is ambiguous
27+
//~^ ERROR `id` is ambiguous
2928
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3029
}

tests/ui/imports/ambiguous-1.stderr

Lines changed: 31 additions & 7 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:10:13
33
|
44
LL | pub use self::evp::*;
55
| ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here
@@ -9,8 +9,8 @@ LL | pub use self::handwritten::*;
99
|
1010
= note: `#[warn(ambiguous_glob_reexports)]` on by default
1111

12-
warning: `id` is ambiguous
13-
--> $DIR/ambiguous-1.rs:27:5
12+
error: `id` is ambiguous
13+
--> $DIR/ambiguous-1.rs:26:5
1414
|
1515
LL | id();
1616
| ^^ ambiguous name
@@ -19,18 +19,42 @@ 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:10: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:12: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: `#[deny(ambiguous_glob_imports)]` on by default
3434

35-
warning: 2 warnings emitted
35+
error: aborting due to 1 previous error; 1 warning emitted
36+
37+
Future incompatibility report: Future breakage diagnostic:
38+
error: `id` is ambiguous
39+
--> $DIR/ambiguous-1.rs:26:5
40+
|
41+
LL | id();
42+
| ^^ ambiguous name
43+
|
44+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
45+
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
46+
= note: ambiguous because of multiple glob imports of a name in the same module
47+
note: `id` could refer to the function imported here
48+
--> $DIR/ambiguous-1.rs:10:13
49+
|
50+
LL | pub use self::evp::*;
51+
| ^^^^^^^^^^^^
52+
= help: consider adding an explicit import of `id` to disambiguate
53+
note: `id` could also refer to the function imported here
54+
--> $DIR/ambiguous-1.rs:12:13
55+
|
56+
LL | pub use self::handwritten::*;
57+
| ^^^^^^^^^^^^^^^^^^^^
58+
= help: consider adding an explicit import of `id` to disambiguate
59+
= note: `#[deny(ambiguous_glob_imports)]` on by default
3660

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)