Skip to content

rustc_parse: improve the error diagnostic for "missing let"#151960

Open
Unique-Usman wants to merge 1 commit intorust-lang:mainfrom
Unique-Usman:ua/missingletleft
Open

rustc_parse: improve the error diagnostic for "missing let"#151960
Unique-Usman wants to merge 1 commit intorust-lang:mainfrom
Unique-Usman:ua/missingletleft

Conversation

@Unique-Usman
Copy link
Contributor

No description provided.

@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 1, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 1, 2026

r? @fee1-dead

rustbot has assigned @fee1-dead.
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

@Unique-Usman
Copy link
Contributor Author

r @estebank

@rust-log-analyzer

This comment has been minimized.

Comment on lines 7 to 8
if Some(_) = x {}
//~^ ERROR mismatched types
//~^ ERROR missing `let`
Copy link
Member

@fmease fmease Feb 1, 2026

Choose a reason for hiding this comment

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

Wait, this renders if Some(_) = x {} syntactically invalid whereas on main it's merely semantically invalid, right? If so, this constitutes a breaking change and is generally not acceptable1.

Footnotes

  1. Unless T-lang is in favor of it (which I doubt) and crater is happy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parser is going to sucessfully parse this, but, the checking happens through the CondCheker(during the parsing process though) as it for all the cond after if and while https://github.com/rust-lang/rust/pull/151960/changes#diff-a278ef012eea7cc71e4c028d8c61c358e7a7cd7e35f846a41c75db09f893b998R4262. Does that constitute to changing from semantically invalidd to synthatically correct ?

If it is, I can limit the changes to

  if Some(_) = y &&
        let Some(_) = z

Copy link
Member

Choose a reason for hiding this comment

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

Check if your PR makes rustc reject the following code. If it does, then it's a breaking change.

fn main() {
    #[cfg(false)]
    if Some(_) = x {}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it is a breaking change, I think I should remove it. What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should not introduce any breaking changes.

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 1, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 1, 2026

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

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 1, 2026
@Unique-Usman Unique-Usman requested a review from fmease February 1, 2026 17:52
@Unique-Usman
Copy link
Contributor Author

This is a continuation of #151493 as commented in #151493 (comment)

@Unique-Usman
Copy link
Contributor Author

r? @estebank

@rustbot rustbot assigned estebank and unassigned fee1-dead Feb 1, 2026
@rust-bors

This comment was marked as resolved.

@JayanAXHF JayanAXHF added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 1, 2026
@Unique-Usman Unique-Usman requested a review from estebank February 1, 2026 19:21
@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 Feb 1, 2026
@rust-log-analyzer

This comment has been minimized.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Unique-Usman Unique-Usman requested a review from estebank February 5, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-diagnostics Area: Messages for errors, warnings, and lints 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.

7 participants