-
Notifications
You must be signed in to change notification settings - Fork 13.9k
remove support for typeof
#148256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
remove support for typeof
#148256
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,10 +195,11 @@ impl<'tcx> InherentCollect<'tcx> { | |
| | ty::Closure(..) | ||
| | ty::CoroutineClosure(..) | ||
| | ty::Coroutine(..) | ||
| | ty::CoroutineWitness(..) => { | ||
| Err(self.tcx.dcx().delayed_bug("cannot define inherent `impl` for closure types")) | ||
| } | ||
| ty::Alias(ty::Free, _) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => { | ||
| | ty::CoroutineWitness(..) | ||
| | ty::Alias(ty::Free, _) | ||
| | ty::Bound(..) | ||
| | ty::Placeholder(_) | ||
| | ty::Infer(_) => { | ||
|
Comment on lines
+198
to
+202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: How is this related to this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, there's currently no way to get unnameable types into impl headers or encounter them in coherence, and it's nice to be able to reason about that |
||
| bug!("unexpected impl self type of impl: {:?} {:?}", id, self_ty); | ||
| } | ||
| // We could bail out here, but that will silence other useful errors. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -328,8 +328,6 @@ impl<'a> Parser<'a> { | |
| // Reference | ||
| self.expect_and()?; | ||
| self.parse_borrowed_pointee()? | ||
| } else if self.eat_keyword_noexpect(kw::Typeof) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be nice to keep a precise error message here and recover into an error type |
||
| self.parse_typeof_ty()? | ||
| } else if self.eat_keyword(exp!(Underscore)) { | ||
| // A type to be inferred `_` | ||
| TyKind::Infer | ||
|
|
@@ -763,15 +761,6 @@ impl<'a> Parser<'a> { | |
| } | ||
| } | ||
|
|
||
| // Parses the `typeof(EXPR)`. | ||
| // To avoid ambiguity, the type is surrounded by parentheses. | ||
| fn parse_typeof_ty(&mut self) -> PResult<'a, TyKind> { | ||
| self.expect(exp!(OpenParen))?; | ||
| let expr = self.parse_expr_anon_const()?; | ||
| self.expect(exp!(CloseParen))?; | ||
| Ok(TyKind::Typeof(expr)) | ||
| } | ||
|
|
||
| /// Parses a function pointer type (`TyKind::FnPtr`). | ||
| /// ```ignore (illustrative) | ||
| /// [unsafe] [extern "ABI"] fn (S) -> T | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: is there a chance this affects macros?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the following artificial snippet will go from pass→fail:
After this PR it'll fail with
no rules expected keyword `typeof`(and hypothetically iftypeofwere to be demoted to a normal identifier, it would start failing withexpected type, found `0`).However, it's very unlikely anybody is relying on it. So it's not really a concern. MBE is notoriously forward incompatible.