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

Rename overlapping_patterns lint #78242

Merged
merged 6 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@ impl IntRange {
pcx.span,
|lint| {
let mut err = lint.build("multiple patterns overlap on their endpoints");
err.span_label(pcx.span, "... with this range");
for (int_range, span) in overlaps {
// Use the real type for user display of the ranges:
err.span_label(
span,
&format!(
Expand All @@ -320,7 +318,8 @@ impl IntRange {
),
);
}
err.note("this is likely to be a mistake");
err.span_label(pcx.span, "... with this range");
Copy link
Member

Choose a reason for hiding this comment

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

Ah, this didn't have the effect I hoped it would. I forget how vertical label ordering is determined: I guess by span location?

Copy link
Member Author

@Nadrieril Nadrieril Dec 20, 2020

Choose a reason for hiding this comment

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

I'm not sure, but I think it's only the tests that involve macros that are confusing. In normal cases the ranges will be on different lines of a match and the messages will be in the order we want them

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's true. Not worth worrying about.

err.note("you likely meant to write mutually exclusive ranges");
err.emit();
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ note: the lint level is defined here
|
LL | #![deny(overlapping_range_endpoints)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: multiple patterns overlap on their endpoints
--> $DIR/overlapping_range_endpoints.rs:16:22
Expand All @@ -21,7 +21,7 @@ LL | m!(0u8, 30..=40, 20..=30);
| |
| this range overlaps on `30_u8`...
|
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: multiple patterns overlap on their endpoints
--> $DIR/overlapping_range_endpoints.rs:19:22
Expand All @@ -31,7 +31,7 @@ LL | m!(0u8, 20.. 30, 29..=40);
| |
| this range overlaps on `29_u8`...
|
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: multiple patterns overlap on their endpoints
--> $DIR/overlapping_range_endpoints.rs:23:22
Expand All @@ -41,7 +41,7 @@ LL | m!(0u8, 20..=30, 30..=31);
| |
| this range overlaps on `30_u8`...
|
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: multiple patterns overlap on their endpoints
--> $DIR/overlapping_range_endpoints.rs:27:22
Expand All @@ -51,7 +51,7 @@ LL | m!(0u8, 20..=30, 19..=20);
| |
| this range overlaps on `20_u8`...
|
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: multiple patterns overlap on their endpoints
--> $DIR/overlapping_range_endpoints.rs:39:9
Expand All @@ -63,7 +63,7 @@ LL | 20..=30 => {}
LL | 10..=20 => {}
| ^^^^^^^ ... with this range
|
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: multiple patterns overlap on their endpoints
--> $DIR/overlapping_range_endpoints.rs:50:16
Expand All @@ -73,7 +73,7 @@ LL | (true, 0..=10) => {}
LL | (true, 10..20) => {}
| ^^^^^^ ... with this range
|
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: multiple patterns overlap on their endpoints
--> $DIR/overlapping_range_endpoints.rs:56:14
Expand All @@ -83,7 +83,7 @@ LL | Some(0..=10) => {}
LL | Some(10..20) => {}
| ^^^^^^ ... with this range
|
= note: this is likely to be a mistake
= note: you likely meant to write mutually exclusive ranges

error: aborting due to 8 previous errors