rust-lang / rust-lang/rust

Detect missing `else` in block with `return`

Open
#135,857 5 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

A-diagnostics A-parser F-let_else P-low T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.