- 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
Conversation
typeof | !ident_token.is_reserved_ident() | ||
| || ident_token.is_path_segment_keyword() | ||
| || [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Typeof, kw::Dyn] | ||
| || [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Dyn] |
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?
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:
macro_rules! ck { ($ty:ty) => {}; } ck!(typeof(0));After this PR it'll fail with no rules expected keyword `typeof` (and hypothetically if typeof were to be demoted to a normal identifier, it would start failing with expected 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.
| | ty::CoroutineWitness(..) | ||
| | ty::Alias(ty::Free, _) | ||
| | ty::Bound(..) | ||
| | ty::Placeholder(_) | ||
| | ty::Infer(_) => { |
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: How is this related to this PR?
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.
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.
With the removal of typeof inference, it should now be impossible to sneak these unnameable types into an impl (even with TAIT you can't do that IINM)
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
| // 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 comment
The 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
see rust-lang/compiler-team#940
r? types