#rustc_interface: collecting which trait impls are actually used

1 messages · Page 1 of 1 (latest)

short veldt
#

I'm trying to figure out whether it is possible to do this.
Given

trait Trait {
    fn plusone(self) -> Self;
}
impl Trait for i32 {
    fn plusone(self) -> Self { self + 1 }
}
impl Trait for usize {
    fn plusone(self) -> Self { self + 2 }
}
fn main() {
    let x = 1;
    println!("{}", x.plusone());
}

I want to get back the info that only impl Trait for i32 is actually used.
I've been reading through various docs for rustc_* crates, including rustc_hir, rustc_hir_typeck, rustc_trait_selection etc to no avail. Also the typechecking-related functionalities are not really exposed, except for seemingly opaque tcx.typeck()...?

lusty violet
#

you're a lot more likely to get results there