Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix tests to handle the Typeof bodies
  • Loading branch information
nikomatsakis committed Mar 1, 2017
1 parent f704ef5 commit d572aa2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/librustc/hir/map/def_collector.rs
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/hir/map/definitions.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -387,7 +389,8 @@ impl DefPathData {
ClosureExpr |
StructCtor |
Initializer |
ImplTrait => None
ImplTrait |
Typeof => None
}
}

Expand Down Expand Up @@ -415,6 +418,7 @@ impl DefPathData {
StructCtor => "{{constructor}}",
Initializer => "{{initializer}}",
ImplTrait => "{{impl-Trait}}",
Typeof => "{{typeof}}",
};

Symbol::intern(s).as_str()
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ty/item_path.rs
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/collect.rs
Expand Up @@ -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,

Expand Down

0 comments on commit d572aa2

Please sign in to comment.