fix tests to handle the Typeof bodies

This commit is contained in:
Niko Matsakis 2017-03-01 17:04:01 -05:00
parent f704ef5ff7
commit d572aa2fd4
4 changed files with 10 additions and 3 deletions

View File

@ -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);

View File

@ -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()

View File

@ -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());

View File

@ -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,