Skip to content

Commit

Permalink
Rollup merge of #100185 - compiler-errors:issue-100183, r=wesleywiser
Browse files Browse the repository at this point in the history
Fix `ReErased` leaking into typeck due to `typeof(...)` recovery

Fixes #100183
  • Loading branch information
GuillaumeGomez authored Sep 12, 2022
2 parents 52e003a + 315d12d commit b7504d6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/typeof/issue-100183.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct Struct {
y: (typeof("hey"),),
//~^ ERROR `typeof` is a reserved keyword but unimplemented
}

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/typeof/issue-100183.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0516]: `typeof` is a reserved keyword but unimplemented
--> $DIR/issue-100183.rs:2:9
|
LL | y: (typeof("hey"),),
| ^^^^^^^^^^^^^ reserved keyword
|
help: consider replacing `typeof(...)` with an actual type
|
LL | y: (&'static str,),
| ~~~~~~~~~~~~

error: aborting due to previous error

For more information about this error, try `rustc --explain E0516`.

0 comments on commit b7504d6

Please sign in to comment.