Skip to content

Detect missing else in block with return #135857

Open
@estebank

Description

@estebank
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 {.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTF-let_elseIssues related to let-else statements (RFC 3137)P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions