mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Add autoderef and autoref tests for future_prelude_collision
lint
This commit is contained in:
parent
327697a540
commit
eb5e0af3a9
@ -12,6 +12,13 @@ impl TryIntoU32 for u8 {
|
||||
}
|
||||
}
|
||||
|
||||
// needed for autoref test
|
||||
impl TryIntoU32 for &f32 {
|
||||
fn try_into(self) -> Result<u32, ()> {
|
||||
Ok(*self as u32)
|
||||
}
|
||||
}
|
||||
|
||||
trait TryFromU8: Sized {
|
||||
fn try_from(x: u8) -> Result<Self, ()>;
|
||||
}
|
||||
@ -54,4 +61,12 @@ 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
|
||||
|
||||
// test autoderef
|
||||
let _: u32 = TryIntoU32::try_into(*(&3u8)).unwrap();
|
||||
//~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
|
||||
|
||||
// test autoref
|
||||
let _: u32 = TryIntoU32::try_into(&3.0).unwrap();
|
||||
//~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
|
||||
}
|
||||
|
@ -12,6 +12,13 @@ impl TryIntoU32 for u8 {
|
||||
}
|
||||
}
|
||||
|
||||
// needed for autoref test
|
||||
impl TryIntoU32 for &f32 {
|
||||
fn try_into(self) -> Result<u32, ()> {
|
||||
Ok(*self as u32)
|
||||
}
|
||||
}
|
||||
|
||||
trait TryFromU8: Sized {
|
||||
fn try_from(x: u8) -> Result<Self, ()>;
|
||||
}
|
||||
@ -54,4 +61,12 @@ fn main() {
|
||||
// test type omission
|
||||
let _: u32 = <_>::try_from(3u8).unwrap();
|
||||
//~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
|
||||
|
||||
// test autoderef
|
||||
let _: u32 = (&3u8).try_into().unwrap();
|
||||
//~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
|
||||
|
||||
// test autoref
|
||||
let _: u32 = 3.0.try_into().unwrap();
|
||||
//~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: trait method `try_into` will become ambiguous in Rust 2021
|
||||
--> $DIR/future-prelude-collision.rs:40:18
|
||||
--> $DIR/future-prelude-collision.rs:47:18
|
||||
|
|
||||
LL | let _: u32 = 3u8.try_into().unwrap();
|
||||
| ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(3u8)`
|
||||
@ -7,22 +7,34 @@ LL | let _: u32 = 3u8.try_into().unwrap();
|
||||
= note: `#[warn(future_prelude_collision)]` on by default
|
||||
|
||||
warning: trait-associated function `try_from` will become ambiguous in Rust 2021
|
||||
--> $DIR/future-prelude-collision.rs:44:13
|
||||
--> $DIR/future-prelude-collision.rs:51:13
|
||||
|
|
||||
LL | let _ = u32::try_from(3u8).unwrap();
|
||||
| ^^^^^^^^^^^^^ help: disambiguate the associated function: `<u32 as TryFromU8>::try_from`
|
||||
|
||||
warning: trait-associated function `from_iter` will become ambiguous in Rust 2021
|
||||
--> $DIR/future-prelude-collision.rs:48:13
|
||||
--> $DIR/future-prelude-collision.rs:55: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: trait-associated function `try_from` will become ambiguous in Rust 2021
|
||||
--> $DIR/future-prelude-collision.rs:55:18
|
||||
--> $DIR/future-prelude-collision.rs:62:18
|
||||
|
|
||||
LL | let _: u32 = <_>::try_from(3u8).unwrap();
|
||||
| ^^^^^^^^^^^^^ help: disambiguate the associated function: `<_ as TryFromU8>::try_from`
|
||||
|
||||
warning: 4 warnings emitted
|
||||
warning: trait method `try_into` will become ambiguous in Rust 2021
|
||||
--> $DIR/future-prelude-collision.rs:66:18
|
||||
|
|
||||
LL | let _: u32 = (&3u8).try_into().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(*(&3u8))`
|
||||
|
||||
warning: trait method `try_into` will become ambiguous in Rust 2021
|
||||
--> $DIR/future-prelude-collision.rs:70:18
|
||||
|
|
||||
LL | let _: u32 = 3.0.try_into().unwrap();
|
||||
| ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(&3.0)`
|
||||
|
||||
warning: 6 warnings emitted
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user