Fix ReErased leaking into typeck due to typeof recovery
This commit is contained in:
parent
d77da9da84
commit
315d12d73d
3 changed files with 24 additions and 1 deletions
|
@ -2667,7 +2667,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
self.normalize_ty(ast_ty.span, array_ty)
|
self.normalize_ty(ast_ty.span, array_ty)
|
||||||
}
|
}
|
||||||
hir::TyKind::Typeof(ref e) => {
|
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;
|
let span = ast_ty.span;
|
||||||
tcx.sess.emit_err(TypeofReservedKeywordUsed {
|
tcx.sess.emit_err(TypeofReservedKeywordUsed {
|
||||||
span,
|
span,
|
||||||
|
|
6
src/test/ui/typeof/issue-100183.rs
Normal file
6
src/test/ui/typeof/issue-100183.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
struct Struct {
|
||||||
|
y: (typeof("hey"),),
|
||||||
|
//~^ ERROR `typeof` is a reserved keyword but unimplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
14
src/test/ui/typeof/issue-100183.stderr
Normal file
14
src/test/ui/typeof/issue-100183.stderr
Normal file
|
@ -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`.
|
Loading…
Add table
Add a link
Reference in a new issue