Skip to content
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

Detect missing else in block with return #135857

Open
estebank opened this issue Jan 22, 2025 · 0 comments
Open

Detect missing else in block with return #135857

estebank opened this issue Jan 22, 2025 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST F-let_else Issues related to let-else statements (RFC 3137) P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

error: expected identifier, found keyword `return`
   --> /home/gh-estebank/rust/compiler/rustc_lint/src/default_could_be_derived.rs:249:13
    |
248 |         let hir::VariantData::Struct { fields, recovered: Recovered::No } = data {
    |                                                                             ---- while parsing this struct
249 |             return;
    |             ^^^^^^ expected identifier, found keyword
    |
help: escape `return` to use it as an identifier
    |
249 |             r#return;
    |             ++

This should detect that there's a missing else: = data else {.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST F-let_else Issues related to let-else statements (RFC 3137) P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 22, 2025
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 A-parser Area: The parsing of Rust source code to an AST F-let_else Issues related to let-else statements (RFC 3137) P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant