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

Do not lint when range is completely included into another one #6603

Merged
merged 2 commits into from
Jan 31, 2021

Conversation

ThibsG
Copy link
Contributor

@ThibsG ThibsG commented Jan 17, 2021

This fix has been developed following this comment.
So this will be linted:

|----------|
        |-----------|

Now this won't be linted:

              |---|
|--------------------|

and this will still lint:

|--------|
|--------------|

Fixes: #5986

changelog: Fix FPs in match_overlapping_arm, when first arm is completely included in second arm

@rust-highfive
Copy link

r? @flip1995

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 17, 2021
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

LGTM. Some more testing would be nice, though.

tests/ui/match_overlapping_arm.rs Show resolved Hide resolved
@flip1995 flip1995 added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 18, 2021
Comment on lines +72 to +76
match 42 {
0..14 => println!("0 .. 14"),
5..10 => println!("5 .. 10"),
_ => (),
}
Copy link
Member

Choose a reason for hiding this comment

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

Huh, shouldn't rustc trigger here? the second arm is unreachable. Well, at least this lint doesn't trigger here.

A quick check on Playground shows that rustc triggers here correctly. So I assume this is a late pass lint in rustc and therefore would only trigger once the clippy lint doesn't trigger anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I was a bit surprise too, I was also waiting for an unreachable warning 😅

@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Jan 31, 2021

📌 Commit 0518911 has been approved by flip1995

bors added a commit that referenced this pull request Jan 31, 2021
Do not lint when range is completely included into another one

This fix has been developed following this [comment](#5986 (comment)).
So this will be linted:
```
|----------|
        |-----------|
```
Now this won't be linted:
```
              |---|
|--------------------|
```
and this will still lint:
```
|--------|
|--------------|
```

Fixes: #5986

changelog: none
@bors
Copy link
Collaborator

bors commented Jan 31, 2021

⌛ Testing commit 0518911 with merge cdc75dc...

@flip1995
Copy link
Member

@bors retry (for changelog)

@bors
Copy link
Collaborator

bors commented Jan 31, 2021

⌛ Testing commit 0518911 with merge c5f3f9d...

@bors
Copy link
Collaborator

bors commented Jan 31, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing c5f3f9d to master...

@bors bors merged commit c5f3f9d into rust-lang:master Jan 31, 2021
@ThibsG ThibsG deleted the MatchOverlappingArm5986 branch January 31, 2021 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

match_overlapping_arm: Does not seem valid
4 participants