Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xizheyin
Copy link
Contributor

@xizheyin xizheyin commented May 5, 2025

Fixes #140169

I added test to the first commit and the second added the code and changes to test.

r? @petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 5, 2025
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 5, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Copy link
Contributor Author

@xizheyin xizheyin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rustbot ready

Comment on lines -399 to +413
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),
Copy link
Contributor Author

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.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 6, 2025
@xizheyin xizheyin changed the title Recover from Fn, FnOnce, FnMut trait with named params Parser: Recover error from named params while parse_path May 6, 2025
@rust-log-analyzer

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fn(a: u8) should get a clear diagnostic
5 participants