Skip to content

Commit d572aa2

Browse files
committed
fix tests to handle the Typeof bodies
1 parent f704ef5 commit d572aa2

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/librustc/hir/map/def_collector.rs

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
259259
TyKind::ImplTrait(..) => {
260260
self.create_def(ty.id, DefPathData::ImplTrait);
261261
}
262+
TyKind::Typeof(ref expr) => self.visit_ast_const_integer(expr),
262263
_ => {}
263264
}
264265
visit::walk_ty(self, ty);

src/librustc/hir/map/definitions.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ pub enum DefPathData {
260260
/// Pattern binding
261261
Binding(InternedString),
262262
/// An `impl Trait` type node.
263-
ImplTrait
263+
ImplTrait,
264+
/// A `typeof` type node.
265+
Typeof,
264266
}
265267

266268
impl Definitions {
@@ -387,7 +389,8 @@ impl DefPathData {
387389
ClosureExpr |
388390
StructCtor |
389391
Initializer |
390-
ImplTrait => None
392+
ImplTrait |
393+
Typeof => None
391394
}
392395
}
393396

@@ -415,6 +418,7 @@ impl DefPathData {
415418
StructCtor => "{{constructor}}",
416419
Initializer => "{{initializer}}",
417420
ImplTrait => "{{impl-Trait}}",
421+
Typeof => "{{typeof}}",
418422
};
419423

420424
Symbol::intern(s).as_str()

src/librustc/ty/item_path.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
180180
data @ DefPathData::MacroDef(..) |
181181
data @ DefPathData::ClosureExpr |
182182
data @ DefPathData::Binding(..) |
183-
data @ DefPathData::ImplTrait => {
183+
data @ DefPathData::ImplTrait |
184+
data @ DefPathData::Typeof => {
184185
let parent_def_id = self.parent_def_id(def_id).unwrap();
185186
self.push_item_path(buffer, parent_def_id);
186187
buffer.push(&data.as_interned_str());

src/librustc_typeck/collect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ fn ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11471147

11481148
NodeExpr(_) => match tcx.hir.get(tcx.hir.get_parent_node(node_id)) {
11491149
NodeTy(&hir::Ty { node: TyArray(_, body), .. }) |
1150+
NodeTy(&hir::Ty { node: TyTypeof(body), .. }) |
11501151
NodeExpr(&hir::Expr { node: ExprRepeat(_, body), .. })
11511152
if body.node_id == node_id => tcx.types.usize,
11521153

0 commit comments

Comments
 (0)