about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-03-01 17:04:01 -0500
committerNiko Matsakis <niko@alum.mit.edu>2017-03-01 17:04:01 -0500
commitd572aa2fd4012698097efa00db6331197f3e44ac (patch)
tree8cc05e382598e5940a584490849b4d98d69a29b3
parentf704ef5ff763f090f3ab98a65c160c830f660302 (diff)
downloadrust-d572aa2fd4012698097efa00db6331197f3e44ac.tar.gz
rust-d572aa2fd4012698097efa00db6331197f3e44ac.zip
fix tests to handle the Typeof bodies
-rw-r--r--src/librustc/hir/map/def_collector.rs1
-rw-r--r--src/librustc/hir/map/definitions.rs8
-rw-r--r--src/librustc/ty/item_path.rs3
-rw-r--r--src/librustc_typeck/collect.rs1
4 files changed, 10 insertions, 3 deletions
diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs
index be8780f39b1..425953c0f4f 100644
--- a/src/librustc/hir/map/def_collector.rs
+++ b/src/librustc/hir/map/def_collector.rs
@@ -259,6 +259,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
             TyKind::ImplTrait(..) => {
                 self.create_def(ty.id, DefPathData::ImplTrait);
             }
+            TyKind::Typeof(ref expr) => self.visit_ast_const_integer(expr),
             _ => {}
         }
         visit::walk_ty(self, ty);
diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs
index b28c5e80ea3..bf52a036cc8 100644
--- a/src/librustc/hir/map/definitions.rs
+++ b/src/librustc/hir/map/definitions.rs
@@ -260,7 +260,9 @@ pub enum DefPathData {
     /// Pattern binding
     Binding(InternedString),
     /// An `impl Trait` type node.
-    ImplTrait
+    ImplTrait,
+    /// A `typeof` type node.
+    Typeof,
 }
 
 impl Definitions {
@@ -387,7 +389,8 @@ impl DefPathData {
             ClosureExpr |
             StructCtor |
             Initializer |
-            ImplTrait => None
+            ImplTrait |
+            Typeof => None
         }
     }
 
@@ -415,6 +418,7 @@ impl DefPathData {
             StructCtor => "{{constructor}}",
             Initializer => "{{initializer}}",
             ImplTrait => "{{impl-Trait}}",
+            Typeof => "{{typeof}}",
         };
 
         Symbol::intern(s).as_str()
diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs
index 7bf1ba155b5..448be7fe9a1 100644
--- a/src/librustc/ty/item_path.rs
+++ b/src/librustc/ty/item_path.rs
@@ -180,7 +180,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
             data @ DefPathData::MacroDef(..) |
             data @ DefPathData::ClosureExpr |
             data @ DefPathData::Binding(..) |
-            data @ DefPathData::ImplTrait => {
+            data @ DefPathData::ImplTrait |
+            data @ DefPathData::Typeof => {
                 let parent_def_id = self.parent_def_id(def_id).unwrap();
                 self.push_item_path(buffer, parent_def_id);
                 buffer.push(&data.as_interned_str());
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 7f413a0dfc3..1f622235af4 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -1147,6 +1147,7 @@ fn ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
         NodeExpr(_) => match tcx.hir.get(tcx.hir.get_parent_node(node_id)) {
             NodeTy(&hir::Ty { node: TyArray(_, body), .. }) |
+            NodeTy(&hir::Ty { node: TyTypeof(body), .. }) |
             NodeExpr(&hir::Expr { node: ExprRepeat(_, body), .. })
                 if body.node_id == node_id => tcx.types.usize,