add trait aliases to typeck

This commit is contained in:
Alex Burka 2017-10-09 17:49:53 +02:00
parent 2eefc9db15
commit 63f1c24d8a
3 changed files with 11 additions and 2 deletions

View file

@ -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)) .map(|id| tcx.hir.local_def_id(id.node_id))
.collect() .collect()
} }
hir::ItemTraitAlias(..) => vec![],
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait") _ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
}; };
Rc::new(vec) Rc::new(vec)

View file

@ -336,6 +336,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
let path = &trait_ref.path; let path = &trait_ref.path;
match path.def { match path.def {
Def::Trait(trait_def_id) => trait_def_id, Def::Trait(trait_def_id) => trait_def_id,
Def::TraitAlias(alias_def_id) => alias_def_id,
Def::Err => { Def::Err => {
self.tcx().sess.fatal("cannot continue compilation due to previous error"); self.tcx().sess.fatal("cannot continue compilation due to previous error");
} }

View file

@ -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.at(it.span).super_predicates_of(def_id);
tcx.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::ItemStruct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => { hir::ItemUnion(ref struct_def, _) => {
tcx.generics_of(def_id); tcx.generics_of(def_id);
@ -672,6 +677,7 @@ fn super_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let (generics, bounds) = match item.node { let (generics, bounds) = match item.node {
hir::ItemTrait(.., ref generics, ref supertraits, _) => (generics, supertraits), hir::ItemTrait(.., ref generics, ref supertraits, _) => (generics, supertraits),
hir::ItemTraitAlias(ref generics, ref supertraits) => (generics, supertraits),
_ => span_bug!(item.span, _ => span_bug!(item.span,
"super_predicates invoked on non-trait"), "super_predicates invoked on non-trait"),
}; };
@ -715,6 +721,7 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let unsafety = match item.node { let unsafety = match item.node {
hir::ItemTrait(_, unsafety, ..) => unsafety, hir::ItemTrait(_, unsafety, ..) => unsafety,
hir::ItemTraitAlias(..) => hir::Unsafety::Normal,
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"), _ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
}; };
@ -902,7 +909,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
(generics, None) (generics, None)
} }
ItemTrait(_, _, ref generics, ..) => { ItemTrait(_, _, ref generics, ..) | ItemTraitAlias(ref generics, ..) => {
// Add in the self type parameter. // Add in the self type parameter.
// //
// Something of a hack: use the node id for the trait, also as // 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>,
tcx.mk_adt(def, substs) tcx.mk_adt(def, substs)
} }
ItemAutoImpl(..) | ItemAutoImpl(..) |
ItemTrait(..) | ItemTrait(..) | ItemTraitAlias(..) |
ItemMod(..) | ItemMod(..) |
ItemForeignMod(..) | ItemForeignMod(..) |
ItemGlobalAsm(..) | ItemGlobalAsm(..) |