Skip to content

Commit 013fca8

Browse files
committed
Generate DefIds for impl Trait in the def_collector
1 parent f8e83a6 commit 013fca8

File tree

5 files changed

+17
-29
lines changed

5 files changed

+17
-29
lines changed

src/librustc/hir/lowering.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,14 +1179,11 @@ impl<'a> LoweringContext<'a> {
11791179
ImplTraitContext::Universal(def_id) => {
11801180
self.lower_node_id(def_node_id);
11811181
// Add a definition for the in-band TyParam
1182-
let def_index = self.resolver.definitions().create_def_with_parent(
1183-
def_id.index,
1184-
def_node_id,
1185-
DefPathData::UniversalImplTrait,
1186-
DefIndexAddressSpace::High,
1187-
Mark::root(),
1188-
span,
1189-
);
1182+
let def_index = self
1183+
.resolver
1184+
.definitions()
1185+
.opt_def_index(def_node_id)
1186+
.unwrap();
11901187

11911188
let hir_bounds = self.lower_param_bounds(bounds, itctx);
11921189
// Set the name to `impl Bound1 + Bound2`
@@ -1254,18 +1251,12 @@ impl<'a> LoweringContext<'a> {
12541251
span,
12551252
);
12561253

1257-
// Pull a new definition from the ether
12581254
let exist_ty_def_index = self
12591255
.resolver
12601256
.definitions()
1261-
.create_def_with_parent(
1262-
fn_def_id.index,
1263-
exist_ty_node_id,
1264-
DefPathData::ExistentialImplTrait,
1265-
DefIndexAddressSpace::High,
1266-
Mark::root(),
1267-
exist_ty_span,
1268-
);
1257+
.opt_def_index(exist_ty_node_id)
1258+
.unwrap();
1259+
12691260

12701261
self.allocate_hir_id_counter(exist_ty_node_id, &"existential impl trait");
12711262

src/librustc/hir/map/def_collector.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
302302
fn visit_ty(&mut self, ty: &'a Ty) {
303303
match ty.node {
304304
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id),
305+
TyKind::ImplTrait(node_id, _) => {
306+
self.create_def(node_id, DefPathData::ImplTrait, REGULAR_SPACE, ty.span);
307+
}
305308
_ => {}
306309
}
307310
visit::walk_ty(self, ty);

src/librustc/hir/map/definitions.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,8 @@ pub enum DefPathData {
374374
StructCtor,
375375
/// A constant expression (see {ast,hir}::AnonConst).
376376
AnonConst,
377-
/// An `impl Trait` type node in argument position.
378-
UniversalImplTrait,
379-
/// An `impl Trait` type node in return position.
380-
ExistentialImplTrait,
377+
/// An `impl Trait` type node
378+
ImplTrait,
381379

382380
/// GlobalMetaData identifies a piece of crate metadata that is global to
383381
/// a whole crate (as opposed to just one item). GlobalMetaData components
@@ -641,8 +639,7 @@ impl DefPathData {
641639
ClosureExpr |
642640
StructCtor |
643641
AnonConst |
644-
ExistentialImplTrait |
645-
UniversalImplTrait => None
642+
ImplTrait => None
646643
}
647644
}
648645

@@ -672,8 +669,7 @@ impl DefPathData {
672669
ClosureExpr => "{{closure}}",
673670
StructCtor => "{{constructor}}",
674671
AnonConst => "{{constant}}",
675-
ExistentialImplTrait => "{{exist-impl-Trait}}",
676-
UniversalImplTrait => "{{univ-impl-Trait}}",
672+
ImplTrait => "{{impl-Trait}}",
677673
};
678674

679675
Symbol::intern(s).as_interned_str()

src/librustc/ty/item_path.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
221221
data @ DefPathData::AnonConst |
222222
data @ DefPathData::MacroDef(..) |
223223
data @ DefPathData::ClosureExpr |
224-
data @ DefPathData::ExistentialImplTrait |
225-
data @ DefPathData::UniversalImplTrait |
224+
data @ DefPathData::ImplTrait |
226225
data @ DefPathData::GlobalMetaData(..) => {
227226
let parent_def_id = self.parent_def_id(def_id).unwrap();
228227
self.push_item_path(buffer, parent_def_id);

src/librustc/util/ppaux.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ impl PrintContext {
291291
DefPathData::Field(_) |
292292
DefPathData::StructCtor |
293293
DefPathData::AnonConst |
294-
DefPathData::ExistentialImplTrait |
295-
DefPathData::UniversalImplTrait |
294+
DefPathData::ImplTrait |
296295
DefPathData::GlobalMetaData(_) => {
297296
// if we're making a symbol for something, there ought
298297
// to be a value or type-def or something in there

0 commit comments

Comments
 (0)