about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJane Lusby <jlusby@yaah.dev>2020-09-26 16:34:09 -0700
committerJane Lusby <jlusby@yaah.dev>2021-04-23 11:07:15 -0700
commit2ac171f94cca347ff3b1ef4c3e13f3566b087e73 (patch)
tree648b1d447730429b09c84ab7c7b1e6482dc0aab2
parent9a352326112e4fd993e339cbd4eabae06d4979b9 (diff)
downloadrust-2ac171f94cca347ff3b1ef4c3e13f3566b087e73.tar.gz
rust-2ac171f94cca347ff3b1ef4c3e13f3566b087e73.zip
try enabling typeof for fun error messages
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs4
-rw-r--r--compiler/rustc_typeck/src/collect/type_of.rs6
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index b6de491911a..34e06e2d5a0 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -2277,9 +2277,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                 let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length));
                 self.normalize_ty(ast_ty.span, array_ty)
             }
-            hir::TyKind::Typeof(ref _e) => {
+            hir::TyKind::Typeof(ref e) => {
                 tcx.sess.emit_err(TypeofReservedKeywordUsed { span: ast_ty.span });
-                tcx.ty_error()
+                tcx.type_of(e.hir_id.owner)
             }
             hir::TyKind::Infer => {
                 // Infer also appears as the type of arguments or return
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs
index d8eea1ad80b..74135c49d58 100644
--- a/compiler/rustc_typeck/src/collect/type_of.rs
+++ b/compiler/rustc_typeck/src/collect/type_of.rs
@@ -417,12 +417,16 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
             let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));
             match parent_node {
                 Node::Ty(&Ty { kind: TyKind::Array(_, ref constant), .. })
-                | Node::Ty(&Ty { kind: TyKind::Typeof(ref constant), .. })
                 | Node::Expr(&Expr { kind: ExprKind::Repeat(_, ref constant), .. })
                     if constant.hir_id == hir_id =>
                 {
                     tcx.types.usize
                 }
+                Node::Ty(&Ty { kind: TyKind::Typeof(ref constant), .. })
+                    if constant.hir_id == hir_id =>
+                {
+                    tcx.typeck(def_id).node_type(constant.hir_id)
+                }
 
                 Node::Expr(&Expr { kind: ExprKind::ConstBlock(ref anon_const), .. })
                     if anon_const.hir_id == hir_id =>