Compute ty_param_owner
using DefIdTree.
This commit is contained in:
parent
dd38eea722
commit
b5dfa6a78d
4 changed files with 13 additions and 15 deletions
|
@ -2265,11 +2265,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
assert_eq!(opt_self_ty, None);
|
||||
self.prohibit_generics(path.segments);
|
||||
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
|
||||
let item_id = tcx.hir().get_parent_node(hir_id);
|
||||
let item_def_id = tcx.hir().local_def_id(item_id);
|
||||
let def_id = def_id.expect_local();
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let item_def_id = tcx.hir().ty_param_owner(def_id);
|
||||
let generics = tcx.generics_of(item_def_id);
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
|
||||
tcx.mk_ty_param(index, tcx.hir().name(hir_id))
|
||||
}
|
||||
Res::SelfTy { trait_: Some(_), alias_to: None } => {
|
||||
|
|
|
@ -184,8 +184,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
|||
_: Ident,
|
||||
) -> ty::GenericPredicates<'tcx> {
|
||||
let tcx = self.tcx;
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
|
||||
let item_def_id = tcx.hir().ty_param_owner(hir_id);
|
||||
let item_def_id = tcx.hir().ty_param_owner(def_id.expect_local());
|
||||
let generics = tcx.generics_of(item_def_id);
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
ty::GenericPredicates {
|
||||
|
|
|
@ -558,7 +558,7 @@ fn type_param_predicates(
|
|||
// `where T: Foo`.
|
||||
|
||||
let param_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let param_owner = tcx.hir().ty_param_owner(param_id);
|
||||
let param_owner = tcx.hir().ty_param_owner(def_id);
|
||||
let generics = tcx.generics_of(param_owner);
|
||||
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
|
||||
let ty = tcx.mk_ty_param(index, tcx.hir().ty_param_name(param_id));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue