Add future_prelude_collision to 2021 compat group
* Add to 2021 compatibility group * Set default to Allow
This commit is contained in:
parent
3efa5b4b83
commit
56108f67b1
@ -3282,7 +3282,11 @@
|
||||
///
|
||||
/// [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),
|
||||
};
|
||||
}
|
||||
|
@ -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!
|
||||
}
|
||||
|
@ -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!
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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!
|
||||
}
|
||||
|
@ -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 @@ fn from_iter(_: Option<()>) {}
|
||||
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!
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user