Generate DefId
s for impl Trait in the def_collector
This commit is contained in:
parent
f8e83a6062
commit
013fca8698
5 changed files with 17 additions and 29 deletions
|
@ -1179,14 +1179,11 @@ impl<'a> LoweringContext<'a> {
|
|||
ImplTraitContext::Universal(def_id) => {
|
||||
self.lower_node_id(def_node_id);
|
||||
// Add a definition for the in-band TyParam
|
||||
let def_index = self.resolver.definitions().create_def_with_parent(
|
||||
def_id.index,
|
||||
def_node_id,
|
||||
DefPathData::UniversalImplTrait,
|
||||
DefIndexAddressSpace::High,
|
||||
Mark::root(),
|
||||
span,
|
||||
);
|
||||
let def_index = self
|
||||
.resolver
|
||||
.definitions()
|
||||
.opt_def_index(def_node_id)
|
||||
.unwrap();
|
||||
|
||||
let hir_bounds = self.lower_param_bounds(bounds, itctx);
|
||||
// Set the name to `impl Bound1 + Bound2`
|
||||
|
@ -1254,18 +1251,12 @@ impl<'a> LoweringContext<'a> {
|
|||
span,
|
||||
);
|
||||
|
||||
// Pull a new definition from the ether
|
||||
let exist_ty_def_index = self
|
||||
.resolver
|
||||
.definitions()
|
||||
.create_def_with_parent(
|
||||
fn_def_id.index,
|
||||
exist_ty_node_id,
|
||||
DefPathData::ExistentialImplTrait,
|
||||
DefIndexAddressSpace::High,
|
||||
Mark::root(),
|
||||
exist_ty_span,
|
||||
);
|
||||
.opt_def_index(exist_ty_node_id)
|
||||
.unwrap();
|
||||
|
||||
|
||||
self.allocate_hir_id_counter(exist_ty_node_id, &"existential impl trait");
|
||||
|
||||
|
|
|
@ -302,6 +302,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
fn visit_ty(&mut self, ty: &'a Ty) {
|
||||
match ty.node {
|
||||
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id),
|
||||
TyKind::ImplTrait(node_id, _) => {
|
||||
self.create_def(node_id, DefPathData::ImplTrait, REGULAR_SPACE, ty.span);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_ty(self, ty);
|
||||
|
|
|
@ -374,10 +374,8 @@ pub enum DefPathData {
|
|||
StructCtor,
|
||||
/// A constant expression (see {ast,hir}::AnonConst).
|
||||
AnonConst,
|
||||
/// An `impl Trait` type node in argument position.
|
||||
UniversalImplTrait,
|
||||
/// An `impl Trait` type node in return position.
|
||||
ExistentialImplTrait,
|
||||
/// An `impl Trait` type node
|
||||
ImplTrait,
|
||||
|
||||
/// GlobalMetaData identifies a piece of crate metadata that is global to
|
||||
/// a whole crate (as opposed to just one item). GlobalMetaData components
|
||||
|
@ -641,8 +639,7 @@ impl DefPathData {
|
|||
ClosureExpr |
|
||||
StructCtor |
|
||||
AnonConst |
|
||||
ExistentialImplTrait |
|
||||
UniversalImplTrait => None
|
||||
ImplTrait => None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,8 +669,7 @@ impl DefPathData {
|
|||
ClosureExpr => "{{closure}}",
|
||||
StructCtor => "{{constructor}}",
|
||||
AnonConst => "{{constant}}",
|
||||
ExistentialImplTrait => "{{exist-impl-Trait}}",
|
||||
UniversalImplTrait => "{{univ-impl-Trait}}",
|
||||
ImplTrait => "{{impl-Trait}}",
|
||||
};
|
||||
|
||||
Symbol::intern(s).as_interned_str()
|
||||
|
|
|
@ -221,8 +221,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
data @ DefPathData::AnonConst |
|
||||
data @ DefPathData::MacroDef(..) |
|
||||
data @ DefPathData::ClosureExpr |
|
||||
data @ DefPathData::ExistentialImplTrait |
|
||||
data @ DefPathData::UniversalImplTrait |
|
||||
data @ DefPathData::ImplTrait |
|
||||
data @ DefPathData::GlobalMetaData(..) => {
|
||||
let parent_def_id = self.parent_def_id(def_id).unwrap();
|
||||
self.push_item_path(buffer, parent_def_id);
|
||||
|
|
|
@ -291,8 +291,7 @@ impl PrintContext {
|
|||
DefPathData::Field(_) |
|
||||
DefPathData::StructCtor |
|
||||
DefPathData::AnonConst |
|
||||
DefPathData::ExistentialImplTrait |
|
||||
DefPathData::UniversalImplTrait |
|
||||
DefPathData::ImplTrait |
|
||||
DefPathData::GlobalMetaData(_) => {
|
||||
// if we're making a symbol for something, there ought
|
||||
// to be a value or type-def or something in there
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue