rust/tests/ui/traits/inheritance/num0.rs
surechen 40ae34194c remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00

23 lines
428 B
Rust

// run-pass
#![allow(dead_code)]
// Extending Num and using inherited static methods
// pretty-expanded FIXME #23616
pub trait NumCast: Sized {
fn from(i: i32) -> Option<Self>;
}
pub trait Num {
fn from_int(i: isize) -> Self;
fn gt(&self, other: &Self) -> bool;
}
pub trait NumExt: NumCast + PartialOrd { }
fn greater_than_one<T:NumExt>(n: &T) -> bool {
n.gt(&NumCast::from(1).unwrap())
}
pub fn main() {}