diff options
| author | jam1garner <8260240+jam1garner@users.noreply.github.com> | 2021-06-15 01:31:00 -0400 |
|---|---|---|
| committer | jam1garner <8260240+jam1garner@users.noreply.github.com> | 2021-06-15 01:48:04 -0400 |
| commit | 56108f67b13416636508fbfd15442a9e18a70e28 (patch) | |
| tree | 967a0bce3067ff09b689272495639e427500d2fc | |
| parent | 3efa5b4b83b3fe72570d50ce73b8382875a4bdfa (diff) | |
| download | rust-56108f67b13416636508fbfd15442a9e18a70e28.tar.gz rust-56108f67b13416636508fbfd15442a9e18a70e28.zip | |
Add future_prelude_collision to 2021 compat group
* Add to 2021 compatibility group * Set default to Allow
7 files changed, 71 insertions, 12 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index cfa7c160b0f..bef675563a4 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3282,7 +3282,11 @@ declare_lint! { /// /// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes pub FUTURE_PRELUDE_COLLISION, - Warn, + Allow, "detects the usage of trait methods which are ambiguous with traits added to the \ prelude in future editions", + @future_incompatible = FutureIncompatibleInfo { + reference: "issue #85684 <https://github.com/rust-lang/rust/issues/85684>", + edition: Some(Edition::Edition2021), + }; } diff --git a/src/test/ui/rust-2021/future-prelude-collision.fixed b/src/test/ui/rust-2021/future-prelude-collision.fixed index 922c0d54a00..9ede9f3a2fb 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.fixed +++ b/src/test/ui/rust-2021/future-prelude-collision.fixed @@ -1,6 +1,7 @@ // run-rustfix // edition:2018 // check-pass +#![warn(future_prelude_collision)] trait TryIntoU32 { fn try_into(self) -> Result<u32, ()>; @@ -52,14 +53,17 @@ fn main() { // test dot-call that will break in 2021 edition let _: u32 = TryIntoU32::try_into(3u8).unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test associated function call that will break in 2021 edition let _ = <u32 as TryFromU8>::try_from(3u8).unwrap(); //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test reverse turbofish too let _ = <Vec<u8> as FromByteIterator>::from_iter(vec![1u8, 2, 3, 4, 5, 6].into_iter()); //~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // negative testing lint (this line should *not* emit a warning) let _: u32 = TryFromU8::try_from(3u8).unwrap(); @@ -67,21 +71,26 @@ fn main() { // test type omission let _: u32 = <_ as TryFromU8>::try_from(3u8).unwrap(); //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test autoderef let _: u32 = TryIntoU32::try_into(*(&3u8)).unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test autoref let _: u32 = TryIntoU32::try_into(&3.0).unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! let mut data = 3u16; let mut_ptr = std::ptr::addr_of_mut!(data); let _: u32 = TryIntoU32::try_into(mut_ptr as *const _).unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! type U32Alias = u32; let _ = <U32Alias as TryFromU8>::try_from(3u8).unwrap(); //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! } diff --git a/src/test/ui/rust-2021/future-prelude-collision.rs b/src/test/ui/rust-2021/future-prelude-collision.rs index 154dde16d9e..914e910396a 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.rs +++ b/src/test/ui/rust-2021/future-prelude-collision.rs @@ -1,6 +1,7 @@ // run-rustfix // edition:2018 // check-pass +#![warn(future_prelude_collision)] trait TryIntoU32 { fn try_into(self) -> Result<u32, ()>; @@ -52,14 +53,17 @@ fn main() { // test dot-call that will break in 2021 edition let _: u32 = 3u8.try_into().unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test associated function call that will break in 2021 edition let _ = u32::try_from(3u8).unwrap(); //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test reverse turbofish too let _ = <Vec<u8>>::from_iter(vec![1u8, 2, 3, 4, 5, 6].into_iter()); //~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // negative testing lint (this line should *not* emit a warning) let _: u32 = TryFromU8::try_from(3u8).unwrap(); @@ -67,21 +71,26 @@ fn main() { // test type omission let _: u32 = <_>::try_from(3u8).unwrap(); //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test autoderef let _: u32 = (&3u8).try_into().unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! // test autoref let _: u32 = 3.0.try_into().unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! let mut data = 3u16; let mut_ptr = std::ptr::addr_of_mut!(data); let _: u32 = mut_ptr.try_into().unwrap(); //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! type U32Alias = u32; let _ = U32Alias::try_from(3u8).unwrap(); //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! } diff --git a/src/test/ui/rust-2021/future-prelude-collision.stderr b/src/test/ui/rust-2021/future-prelude-collision.stderr index 9c92074c36f..190145ef4db 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.stderr +++ b/src/test/ui/rust-2021/future-prelude-collision.stderr @@ -1,52 +1,79 @@ warning: trait method `try_into` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:53:18 + --> $DIR/future-prelude-collision.rs:54:18 | LL | let _: u32 = 3u8.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(3u8)` | - = note: `#[warn(future_prelude_collision)]` on by default +note: the lint level is defined here + --> $DIR/future-prelude-collision.rs:4:9 + | +LL | #![warn(future_prelude_collision)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: trait-associated function `try_from` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:57:13 + --> $DIR/future-prelude-collision.rs:59:13 | LL | let _ = u32::try_from(3u8).unwrap(); | ^^^^^^^^^^^^^ help: disambiguate the associated function: `<u32 as TryFromU8>::try_from` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: trait-associated function `from_iter` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:61:13 + --> $DIR/future-prelude-collision.rs:64:13 | LL | let _ = <Vec<u8>>::from_iter(vec![1u8, 2, 3, 4, 5, 6].into_iter()); | ^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Vec<u8> as FromByteIterator>::from_iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: trait-associated function `try_from` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:68:18 + --> $DIR/future-prelude-collision.rs:72:18 | LL | let _: u32 = <_>::try_from(3u8).unwrap(); | ^^^^^^^^^^^^^ help: disambiguate the associated function: `<_ as TryFromU8>::try_from` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: trait method `try_into` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:72:18 + --> $DIR/future-prelude-collision.rs:77:18 | LL | let _: u32 = (&3u8).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(*(&3u8))` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: trait method `try_into` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:76:18 + --> $DIR/future-prelude-collision.rs:82:18 | LL | let _: u32 = 3.0.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(&3.0)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: trait method `try_into` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:81:18 + --> $DIR/future-prelude-collision.rs:88:18 | LL | let _: u32 = mut_ptr.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(mut_ptr as *const _)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: trait-associated function `try_from` will become ambiguous in Rust 2021 - --> $DIR/future-prelude-collision.rs:85:13 + --> $DIR/future-prelude-collision.rs:93:13 | LL | let _ = U32Alias::try_from(3u8).unwrap(); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<U32Alias as TryFromU8>::try_from` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: 8 warnings emitted diff --git a/src/test/ui/rust-2021/generic-type-collision.fixed b/src/test/ui/rust-2021/generic-type-collision.fixed index 1ae2b95d515..00fb128a981 100644 --- a/src/test/ui/rust-2021/generic-type-collision.fixed +++ b/src/test/ui/rust-2021/generic-type-collision.fixed @@ -1,6 +1,7 @@ // check-pass // run-rustfix // edition 2018 +#![warn(future_prelude_collision)] trait MyTrait<A> { fn from_iter(x: Option<A>); @@ -13,4 +14,5 @@ impl<T> MyTrait<()> for Vec<T> { fn main() { <Vec<i32> as MyTrait<_>>::from_iter(None); //~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! } diff --git a/src/test/ui/rust-2021/generic-type-collision.rs b/src/test/ui/rust-2021/generic-type-collision.rs index e203656163c..406fba4d247 100644 --- a/src/test/ui/rust-2021/generic-type-collision.rs +++ b/src/test/ui/rust-2021/generic-type-collision.rs @@ -1,6 +1,7 @@ // check-pass // run-rustfix // edition 2018 +#![warn(future_prelude_collision)] trait MyTrait<A> { fn from_iter(x: Option<A>); @@ -13,4 +14,5 @@ impl<T> MyTrait<()> for Vec<T> { fn main() { <Vec<i32>>::from_iter(None); //~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021 + //~^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! } diff --git a/src/test/ui/rust-2021/generic-type-collision.stderr b/src/test/ui/rust-2021/generic-type-collision.stderr index 3acc6185a61..9374379d247 100644 --- a/src/test/ui/rust-2021/generic-type-collision.stderr +++ b/src/test/ui/rust-2021/generic-type-collision.stderr @@ -1,10 +1,16 @@ warning: trait-associated function `from_iter` will become ambiguous in Rust 2021 - --> $DIR/generic-type-collision.rs:14:5 + --> $DIR/generic-type-collision.rs:15:5 | LL | <Vec<i32>>::from_iter(None); | ^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Vec<i32> as MyTrait<_>>::from_iter` | - = note: `#[warn(future_prelude_collision)]` on by default +note: the lint level is defined here + --> $DIR/generic-type-collision.rs:4:9 + | +LL | #![warn(future_prelude_collision)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition! + = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> warning: 1 warning emitted |
