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,