This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +115
-0
lines changed Expand file tree Collapse file tree 3 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ // run-rustfix
2+ // edition:2018
3+ // check-pass
4+ #![ warn( rust_2021_prelude_collisions) ]
5+ #![ allow( unreachable_code) ]
6+
7+ macro_rules! foo {
8+ ( ) => { {
9+ 123 ;
10+ S
11+ } } ;
12+ }
13+
14+ trait MyTry < T > {
15+ fn try_into ( self , _: u8 ) ;
16+ }
17+
18+ struct S ;
19+
20+ impl MyTry < i32 > for S {
21+ fn try_into ( self , _: u8 ) { }
22+ }
23+
24+ trait TryFromU8 : Sized {
25+ fn try_from ( _: u8 ) ;
26+ }
27+
28+ impl TryFromU8 for u32 {
29+ fn try_from ( _: u8 ) { }
30+ }
31+
32+ macro_rules! bar {
33+ ( ) => {
34+ u32
35+ } ;
36+ }
37+
38+ fn main ( ) {
39+ MyTry :: try_into ( foo ! ( ) , todo ! ( ) ) ;
40+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
41+ //~| WARNING this is accepted in the current edition
42+ <bar ! ( ) as TryFromU8 >:: try_from ( 0 ) ;
43+ //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
44+ //~| WARNING this is accepted in the current edition
45+ }
Original file line number Diff line number Diff line change 1+ // run-rustfix
2+ // edition:2018
3+ // check-pass
4+ #![ warn( rust_2021_prelude_collisions) ]
5+ #![ allow( unreachable_code) ]
6+
7+ macro_rules! foo {
8+ ( ) => { {
9+ 123 ;
10+ S
11+ } } ;
12+ }
13+
14+ trait MyTry < T > {
15+ fn try_into ( self , _: u8 ) ;
16+ }
17+
18+ struct S ;
19+
20+ impl MyTry < i32 > for S {
21+ fn try_into ( self , _: u8 ) { }
22+ }
23+
24+ trait TryFromU8 : Sized {
25+ fn try_from ( _: u8 ) ;
26+ }
27+
28+ impl TryFromU8 for u32 {
29+ fn try_from ( _: u8 ) { }
30+ }
31+
32+ macro_rules! bar {
33+ ( ) => {
34+ u32
35+ } ;
36+ }
37+
38+ fn main ( ) {
39+ foo ! ( ) . try_into ( todo ! ( ) ) ;
40+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
41+ //~| WARNING this is accepted in the current edition
42+ <bar ! ( ) >:: try_from ( 0 ) ;
43+ //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
44+ //~| WARNING this is accepted in the current edition
45+ }
Original file line number Diff line number Diff line change 1+ warning: trait method `try_into` will become ambiguous in Rust 2021
2+ --> $DIR/future-prelude-collision-macros.rs:39:5
3+ |
4+ LL | foo!().try_into(todo!());
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyTry::try_into(foo!(), todo!())`
6+ |
7+ note: the lint level is defined here
8+ --> $DIR/future-prelude-collision-macros.rs:4:9
9+ |
10+ LL | #![warn(rust_2021_prelude_collisions)]
11+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
13+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
14+
15+ warning: trait-associated function `try_from` will become ambiguous in Rust 2021
16+ --> $DIR/future-prelude-collision-macros.rs:42:5
17+ |
18+ LL | <bar!()>::try_from(0);
19+ | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<bar!() as TryFromU8>::try_from`
20+ |
21+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
22+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
23+
24+ warning: 2 warnings emitted
25+
You can’t perform that action at this time.
0 commit comments