]> git.lizzy.rs Git - rust.git/commitdiff
add trait aliases to typeck
authorAlex Burka <aburka@seas.upenn.edu>
Mon, 9 Oct 2017 15:49:53 +0000 (17:49 +0200)
committerAlex Burka <aburka@seas.upenn.edu>
Thu, 14 Dec 2017 17:56:26 +0000 (12:56 -0500)
src/librustc/ty/mod.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/collect.rs

index 93ef29855ce1d7e313d13715090fffb3db868f3d..4e1a79d4613e739361dffc48135bcd94809df875 100644 (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))
                           .collect()
         }
+        hir::ItemTraitAlias(..) => vec![],
         _ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
     };
     Rc::new(vec)
index 83aec27c15315d4e5af72a1873e9010753be9cb1..6b37a30cb82d84e9058c40e1021cb0a50ecba892 100644 (file)
@@ -336,6 +336,7 @@ fn trait_def_id(&self, trait_ref: &hir::TraitRef) -> DefId {
         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");
             }
index 85b926a707db3da1c8694bd4f6a3fef707a8da3e..918146605fd4dce5c3cac4c7a59b0f97f69078a9 100644 (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.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);
@@ -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"),
     };
@@ -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"),
     };
 
@@ -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
@@ -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(..) |