Hi, I am playing Rust Compiler Internals at the MIR level. However, I don't understand how to get the trait bound applied to the generic parameter. For example,
impl<T: trait2> trait1 for [T] {
fn function1(&self) -> return_ty {
// resolved implementation
std::mem::transmute(self)
}
}
impl trait_bnd for u8 {}
impl trait_bnd for i8 {}
When I visited mir::statement of the method function1 defined in the trait1, I found that T was considered TyKind::Param which could be an arbitrary type. However, it was actually not any type because T had a trait bound for trait2. Therefore, T could only be u8 and i8 (if we assume trait2 is sealed).
Back to the problem:
How do I know T is bound to trait2 (or how could I know T should be u8/i8?) when I visit the function1 at the MIR level?