Skip to content

Commit

Permalink
add trait aliases to typeck
Browse files Browse the repository at this point in the history
  • Loading branch information
durka committed Dec 14, 2017
1 parent 2eefc9d commit 63f1c24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/librustc/ty/mod.rs
Expand Up @@ -2577,6 +2577,7 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
.map(|id| tcx.hir.local_def_id(id.node_id))
.collect()
}
hir::ItemTraitAlias(..) => vec![],
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
};
Rc::new(vec)
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -336,6 +336,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
let path = &trait_ref.path;
match path.def {
Def::Trait(trait_def_id) => trait_def_id,
Def::TraitAlias(alias_def_id) => alias_def_id,
Def::Err => {
self.tcx().sess.fatal("cannot continue compilation due to previous error");
}
Expand Down
11 changes: 9 additions & 2 deletions src/librustc_typeck/collect.rs
Expand Up @@ -441,6 +441,11 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
tcx.at(it.span).super_predicates_of(def_id);
tcx.predicates_of(def_id);
},
hir::ItemTraitAlias(..) => {
tcx.generics_of(def_id);
tcx.trait_def(def_id);
tcx.predicates_of(def_id);
},
hir::ItemStruct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => {
tcx.generics_of(def_id);
Expand Down Expand Up @@ -672,6 +677,7 @@ fn super_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

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

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

Expand Down Expand Up @@ -902,7 +909,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
(generics, None)
}

ItemTrait(_, _, ref generics, ..) => {
ItemTrait(_, _, ref generics, ..) | ItemTraitAlias(ref generics, ..) => {
// Add in the self type parameter.
//
// Something of a hack: use the node id for the trait, also as
Expand Down Expand Up @@ -1132,7 +1139,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.mk_adt(def, substs)
}
ItemAutoImpl(..) |
ItemTrait(..) |
ItemTrait(..) | ItemTraitAlias(..) |
ItemMod(..) |
ItemForeignMod(..) |
ItemGlobalAsm(..) |
Expand Down

0 comments on commit 63f1c24

Please sign in to comment.