2021-06-17 10:10:38 +00:00
|
|
|
// edition:2018
|
2021-07-01 11:35:33 +00:00
|
|
|
#![warn(rust_2021_prelude_collisions)]
|
2021-06-17 10:10:38 +00:00
|
|
|
#![allow(dead_code)]
|
2021-06-19 22:42:24 +00:00
|
|
|
#![allow(unused_imports)]
|
2021-06-17 10:10:38 +00:00
|
|
|
|
|
|
|
mod m {
|
|
|
|
pub trait TryIntoU32 {
|
|
|
|
fn try_into(self) -> Result<u32, ()>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryIntoU32 for u8 {
|
|
|
|
fn try_into(self) -> Result<u32, ()> {
|
|
|
|
Ok(self as u32)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait AnotherTrick {}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod d {
|
|
|
|
use crate::m::AnotherTrick as TryIntoU32;
|
|
|
|
use crate::m::*;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Here, `TryIntoU32` is imported but shadowed, but in that case we don't permit its methods
|
|
|
|
// to be available.
|
|
|
|
let _: u32 = 3u8.try_into().unwrap();
|
2021-06-19 22:42:24 +00:00
|
|
|
//~^ ERROR no method named `try_into` found for type `u8` in the current scope
|
2021-06-17 10:10:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|