Skip to content

Commit 89a9867

Browse files
committed
Add test for glob imported prelude collision trait.
1 parent 51e4fba commit 89a9867

3 files changed

+32
-1
lines changed

src/test/ui/rust-2021/future-prelude-collision-imported.fixed

+11
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,15 @@ mod c {
5656
}
5757
}
5858

59+
mod d {
60+
use super::m::*;
61+
62+
fn main() {
63+
// See https://github.com/rust-lang/rust/issues/88471
64+
let _: u32 = TryIntoU32::try_into(3u8).unwrap();
65+
//~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
66+
//~^^ WARNING this is accepted in the current edition
67+
}
68+
}
69+
5970
fn main() {}

src/test/ui/rust-2021/future-prelude-collision-imported.rs

+11
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,15 @@ mod c {
5656
}
5757
}
5858

59+
mod d {
60+
use super::m::*;
61+
62+
fn main() {
63+
// See https://github.com/rust-lang/rust/issues/88471
64+
let _: u32 = 3u8.try_into().unwrap();
65+
//~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
66+
//~^^ WARNING this is accepted in the current edition
67+
}
68+
}
69+
5970
fn main() {}

src/test/ui/rust-2021/future-prelude-collision-imported.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,14 @@ LL | let _: u32 = 3u8.try_into().unwrap();
3030
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
3131
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
3232

33-
warning: 3 warnings emitted
33+
warning: trait method `try_into` will become ambiguous in Rust 2021
34+
--> $DIR/future-prelude-collision-imported.rs:64:22
35+
|
36+
LL | let _: u32 = 3u8.try_into().unwrap();
37+
| ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(3u8)`
38+
|
39+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
40+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
41+
42+
warning: 4 warnings emitted
3443

0 commit comments

Comments
 (0)