-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Give correct suggestion for a typo in raw pointers #145903
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?
Conversation
@@ -276,6 +276,34 @@ impl<'a> Parser<'a> { | |||
) -> PResult<'a, Box<Ty>> { | |||
let allow_qpath_recovery = recover_qpath == RecoverQPath::Yes; | |||
maybe_recover_from_interpolated_ty_qpath!(self, allow_qpath_recovery); | |||
|
|||
if (self.token.is_keyword(kw::Const) || self.token.is_keyword(kw::Mut)) |
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.
This probably should also be moved into a separate function and also moved way down into the actually if else
chain below rather than being hit first on every call to parse_ty_common
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.
This was made exactly like attribute parsing in types right below, this why I originally chose this place and this strategy
About snapshoting I'm not fully sure I can and should use it here, not only because I fully know how and why it should be used, I checked other places where snapshotting was used and it mostly like in Err
branch of match
which I don't use
About eat
ing Star
it looks correct for me here even if we know that here is Star
100% beacuse we checked it in if
, but if there any other way more better way to do I'm in full ears, but honestly I dont personally like this if
branch here because of unreachable!
, so yeah, should be a better way to do it,
I also adressed a wording problem, new one should be more straighforward and clear for end user
And I made a recovery as a TyKind::Ptr
, agree that this is better generally
Also about lookahead(2)
or can_begin_type
I'm not quite sure why we need it, I'm parsing type in if
with parse_ty_no_question_mark_recover
to create a TyKind::Ptr
from it, and if there will be no type at all it should fail earlier with a different error
18a0d8e
to
86b7749
Compare
@rustbot ready |
This adds a check for when user wrote
const* T
instead of*const T
, I just saw how a C-person made this typo and compiler suggests thiswhich is very incorrect
also fixes #136602
r? compiler