Skip to content

Recover param: Ty = EXPR #137396

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 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

Fixes #137310

Pretty basic recovery here, but better than giving an unexpected token error.

@rustbot
Copy link
Collaborator

rustbot commented Feb 21, 2025

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Feb 21, 2025
@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 22, 2025

r? fmease

@rustbot rustbot assigned fmease and unassigned BoxyUwU Feb 22, 2025
@compiler-errors compiler-errors force-pushed the param-default branch 2 times, most recently from 3ddd6ac to 70a1e44 Compare February 22, 2025 02:11
Copy link
Member

@fmease fmease Feb 22, 2025

Choose a reason for hiding this comment

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

On a second glance, I would think parse_param_general is 'a better fit' for this compared to parse_ty_for_param (which should probably only concern itself with parsing types).

Mostly an organizational nitpick since it shouldn't be able to affect behavior (CC anon params in Rust 2015). I was only able to find trait T { fn f((x)=0 fn) {} } which will emit two errors under this PR in Rust 2015 (parameter defaults are not supported and expected `:`, found `=`) instead of one and would keep emitting a single one if the logic was moved into parse_param_general I think but that's hardly interesting.

nw, r=me then

r=me with or without moving the logic into parse_param_general. Sorry for the churn / wrong signal there.

Copy link
Member

@fmease fmease Feb 22, 2025

Choose a reason for hiding this comment

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

(preexisting: the patterns aren't allowed in methods without bodies parser recovery is fragile already: it suggests the more butchered _: )=0 for trait T { fn f((x)=0); } under Rust 2015)

@fmease fmease 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 Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Unsupported default function parameters should have an explicit diagnostic
4 participants