2024-02-16 14:02:50 -06:00
|
|
|
//@ edition:2018
|
2021-07-01 06:35:33 -05:00
|
|
|
#![warn(rust_2021_prelude_collisions)]
|
2021-06-17 05:10:38 -05:00
|
|
|
#![allow(dead_code)]
|
2021-06-19 17:42:24 -05:00
|
|
|
#![allow(unused_imports)]
|
2021-06-17 05:10:38 -05: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 17:42:24 -05:00
|
|
|
//~^ ERROR no method named `try_into` found for type `u8` in the current scope
|
2021-06-17 05:10:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|