Skip to content

Commit 630350d

Browse files
committed
Generate DefIds for impl Trait in the def_collector
1 parent eedaba9 commit 630350d

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
@@ -1153,18 +1153,12 @@ impl<'a> LoweringContext<'a> {
11531153
t.span,
11541154
);
11551155

1156-
// Pull a new definition from the ether
11571156
let exist_ty_def_index = self
11581157
.resolver
11591158
.definitions()
1160-
.create_def_with_parent(
1161-
fn_def_id.index,
1162-
def_node_id,
1163-
DefPathData::ExistentialImplTrait,
1164-
DefIndexAddressSpace::High,
1165-
Mark::root(),
1166-
exist_ty_span,
1167-
);
1159+
.opt_def_index(def_node_id)
1160+
.unwrap();
1161+
11681162

11691163
// the `t` is just for printing debug messages
11701164
self.allocate_hir_id_counter(def_node_id, t);
@@ -1227,14 +1221,11 @@ impl<'a> LoweringContext<'a> {
12271221
ImplTraitContext::Universal(def_id, in_band_ty_params) => {
12281222
self.lower_node_id(def_node_id);
12291223
// Add a definition for the in-band TyParam
1230-
let def_index = self.resolver.definitions().create_def_with_parent(
1231-
def_id.index,
1232-
def_node_id,
1233-
DefPathData::UniversalImplTrait,
1234-
DefIndexAddressSpace::High,
1235-
Mark::root(),
1236-
span,
1237-
);
1224+
let def_index = self
1225+
.resolver
1226+
.definitions()
1227+
.opt_def_index(def_node_id)
1228+
.unwrap();
12381229

12391230
let hir_bounds = self.lower_bounds(
12401231
bounds,

src/librustc/hir/map/def_collector.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
256256
fn visit_ty(&mut self, ty: &'a Ty) {
257257
match ty.node {
258258
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id),
259+
TyKind::ImplTrait(node_id, _) => {
260+
self.create_def(node_id, DefPathData::ImplTrait, REGULAR_SPACE, ty.span);
261+
}
259262
_ => {}
260263
}
261264
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
@@ -369,10 +369,8 @@ pub enum DefPathData {
369369
StructCtor,
370370
/// A constant expression (see {ast,hir}::AnonConst).
371371
AnonConst,
372-
/// An `impl Trait` type node in argument position.
373-
UniversalImplTrait,
374-
/// An `impl Trait` type node in return position.
375-
ExistentialImplTrait,
372+
/// An `impl Trait` type node
373+
ImplTrait,
376374

377375
/// GlobalMetaData identifies a piece of crate metadata that is global to
378376
/// a whole crate (as opposed to just one item). GlobalMetaData components
@@ -636,8 +634,7 @@ impl DefPathData {
636634
ClosureExpr |
637635
StructCtor |
638636
AnonConst |
639-
ExistentialImplTrait |
640-
UniversalImplTrait => None
637+
ImplTrait => None
641638
}
642639
}
643640

@@ -667,8 +664,7 @@ impl DefPathData {
667664
ClosureExpr => "{{closure}}",
668665
StructCtor => "{{constructor}}",
669666
AnonConst => "{{constant}}",
670-
ExistentialImplTrait => "{{exist-impl-Trait}}",
671-
UniversalImplTrait => "{{univ-impl-Trait}}",
667+
ImplTrait => "{{impl-Trait}}",
672668
};
673669

674670
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)