Add note when inherent impl for a alias type defined outside of the crate by xizheyin · Pull Request #142415 · rust-lang/rust (original) (raw)
I've tried using type_of before, but I don't seem to be getting the information I'm looking for. When I try this code
let ty = self.tcx.type_of(impl_def_id).skip_binder();
if let ty::Adt(def, _) = ty.kind() {
let def_id = def.did();
let ty_name = self.tcx.def_path_str(def_id);
let alias_ty_name = self.tcx.type_of(def_id).skip_binder().to_string();
println!("ty_name: {:?}", ty_name);
println!("alias_ty_name: {:?}", alias_ty_name);
}
it prints:
ty_name: "Rc"
alias_ty_name: "Rc<T, A>"
It should be:
ty_name: "Function"
alias_ty_name: "Rc<Foo>"
Local variable ty is a adt of type Rc. Maybe the information we need only exists in HIR? Or am I using it wrong?