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

Resolve error messages: more back-ticks, less colons #6402

Closed
wants to merge 1 commit into from
Closed

Resolve error messages: more back-ticks, less colons #6402

wants to merge 1 commit into from

Conversation

kud1ing
Copy link

@kud1ing kud1ing commented May 10, 2013

No description provided.

bors added a commit that referenced this pull request May 11, 2013
@bors bors closed this May 12, 2013
flip1995 added a commit to flip1995/rust that referenced this pull request Dec 6, 2020
Add Collapsible match lint

changelog: Add collapsible_match lint

Closes rust-lang#1252
Closes rust-lang#2521

This lint finds nested `match` or `if let` patterns that can be squashed together. It is designed to be very conservative to only find cases where merging the patterns would most likely reduce cognitive complexity.

Example:

```rust
match result {
    Ok(opt) => match opt {
        Some(x) => x,
        _ => return,
    }
    _ => return,
}
```
to
```rust
match result {
    Ok(Some(x)) => x,
    _ => return,
}
```

These criteria must be met for the lint to fire:

* The inner match has exactly 2 branches.
* Both the outer and inner match have a "wild" branch like `_ => ..`. There is a special case for `None => ..` to also be considered "wild-like".
* The contents of the wild branches are identical.
* The binding which "links" the matches is never used elsewhere.

Thanks to the hir, `if let`'s are easily included with this lint since they are desugared into equivalent `match`'es.

I think this would fit into the style category, but I would also understand changing it to pedantic.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 6, 2020
Rollup of 4 pull requests

Successful merges:

 - rust-lang#6308 (add `internal-lints` feature to enable clippys internal lints (off by default))
 - rust-lang#6395 (switch Version/VersionReq usages to RustcVersion )
 - rust-lang#6402 (Add Collapsible match lint)
 - rust-lang#6407 (CONTRIBUTING: update bors queue url from buildbot2.rlo to bors.rlo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

changelog: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants