about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-09-12 22:47:13 +0200
committerGitHub <noreply@github.com>2022-09-12 22:47:13 +0200
commitb7504d6f4f418f991274c6e062111348c55afb3a (patch)
tree06a44ee5e96155d32751a9866ee9f7cb65229f9a /compiler
parent52e003a6e93940ae49cbfc806c72ed5b0217cf4e (diff)
parent315d12d73d511efb277426c813e5d40157a0d70a (diff)
downloadrust-b7504d6f4f418f991274c6e062111348c55afb3a.tar.gz
rust-b7504d6f4f418f991274c6e062111348c55afb3a.zip
Rollup merge of #100185 - compiler-errors:issue-100183, r=wesleywiser
Fix `ReErased` leaking into typeck due to `typeof(...)` recovery

Fixes #100183
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index d9789d5aaf0..95c7e3e39aa 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -2672,7 +2672,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                 self.normalize_ty(ast_ty.span, array_ty)
             }
             hir::TyKind::Typeof(ref e) => {
-                let ty = tcx.type_of(tcx.hir().local_def_id(e.hir_id));
+                let ty_erased = tcx.type_of(tcx.hir().local_def_id(e.hir_id));
+                let ty = tcx.fold_regions(ty_erased, |r, _| {
+                    if r.is_erased() { tcx.lifetimes.re_static } else { r }
+                });
                 let span = ast_ty.span;
                 tcx.sess.emit_err(TypeofReservedKeywordUsed {
                     span,