-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Parser: Recover error from named params while parse_path #140671
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
Signed-off-by: xizheyin <[email protected]>
This comment has been minimized.
This comment has been minimized.
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
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.
@rustbot ready
let (inputs, _) = match self.parse_paren_comma_seq(|p| p.parse_ty()) { | ||
Ok(output) => output, | ||
let dcx = self.dcx(); | ||
let (inputs, _) = match self.parse_paren_comma_seq(|p| { | ||
if p.is_named_param() { | ||
let param = p.parse_param_general(|_| false, false); | ||
if let Ok(ref param) = param { | ||
dcx.emit_err(FnPathFoundNamedParams { | ||
named_param_span: param.pat.span, | ||
}); | ||
} | ||
param.map(|param| param.ty) | ||
} else { | ||
p.parse_ty() | ||
} | ||
}) { | ||
Ok((output, trailing)) => (output, trailing), |
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.
Now, I used parse_param_general instead of the original parse_ty, and report errors when encountering a named paramter. It seems to make sense.
Fn
, FnOnce
, FnMut
trait with named params
This comment has been minimized.
This comment has been minimized.
Signed-off-by: xizheyin <[email protected]>
Fixes #140169
I added test to the first commit and the second added the code and changes to test.
r? @petrochenkov