Skip to content

Commit 63f1c24

Browse files
committed
add trait aliases to typeck
1 parent 2eefc9d commit 63f1c24

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/librustc/ty/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,7 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
25772577
.map(|id| tcx.hir.local_def_id(id.node_id))
25782578
.collect()
25792579
}
2580+
hir::ItemTraitAlias(..) => vec![],
25802581
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
25812582
};
25822583
Rc::new(vec)

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
336336
let path = &trait_ref.path;
337337
match path.def {
338338
Def::Trait(trait_def_id) => trait_def_id,
339+
Def::TraitAlias(alias_def_id) => alias_def_id,
339340
Def::Err => {
340341
self.tcx().sess.fatal("cannot continue compilation due to previous error");
341342
}

src/librustc_typeck/collect.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
441441
tcx.at(it.span).super_predicates_of(def_id);
442442
tcx.predicates_of(def_id);
443443
},
444+
hir::ItemTraitAlias(..) => {
445+
tcx.generics_of(def_id);
446+
tcx.trait_def(def_id);
447+
tcx.predicates_of(def_id);
448+
},
444449
hir::ItemStruct(ref struct_def, _) |
445450
hir::ItemUnion(ref struct_def, _) => {
446451
tcx.generics_of(def_id);
@@ -672,6 +677,7 @@ fn super_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
672677

673678
let (generics, bounds) = match item.node {
674679
hir::ItemTrait(.., ref generics, ref supertraits, _) => (generics, supertraits),
680+
hir::ItemTraitAlias(ref generics, ref supertraits) => (generics, supertraits),
675681
_ => span_bug!(item.span,
676682
"super_predicates invoked on non-trait"),
677683
};
@@ -715,6 +721,7 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
715721

716722
let unsafety = match item.node {
717723
hir::ItemTrait(_, unsafety, ..) => unsafety,
724+
hir::ItemTraitAlias(..) => hir::Unsafety::Normal,
718725
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
719726
};
720727

@@ -902,7 +909,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
902909
(generics, None)
903910
}
904911

905-
ItemTrait(_, _, ref generics, ..) => {
912+
ItemTrait(_, _, ref generics, ..) | ItemTraitAlias(ref generics, ..) => {
906913
// Add in the self type parameter.
907914
//
908915
// Something of a hack: use the node id for the trait, also as
@@ -1132,7 +1139,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11321139
tcx.mk_adt(def, substs)
11331140
}
11341141
ItemAutoImpl(..) |
1135-
ItemTrait(..) |
1142+
ItemTrait(..) | ItemTraitAlias(..) |
11361143
ItemMod(..) |
11371144
ItemForeignMod(..) |
11381145
ItemGlobalAsm(..) |

0 commit comments

Comments
 (0)