Skip to content

correctly check exclusive range patterns for overlap #1490

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

Merged
merged 3 commits into from
Jan 31, 2017

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jan 30, 2017

No description provided.

@oli-obk oli-obk force-pushed the excl_range_pat_overlap branch from 5d8a648 to aebdf74 Compare January 30, 2017 11:30
Copy link
Member

@mcarton mcarton left a comment

Choose a reason for hiding this comment

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

r+ modulo small nits

@@ -246,11 +247,35 @@ fn overlapping() {
}

match 42 {
2 => println!("2"), //~NOTE overlaps with this
0 ... 2 => println!("0 ... 5"), //~ERROR: some ranges overlap
Copy link
Member

Choose a reason for hiding this comment

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

The string is wrong here.


match 42 {
0 .. 10 => println!("0 ... 10"),
10 .. 50 => println!("0 ... 10"),
Copy link
Member

Choose a reason for hiding this comment

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

Same.

}

match 42 {
0 .. 11 => println!("0 ... 10"), //~ERROR: some ranges overlap
Copy link
Member

Choose a reason for hiding this comment

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

Same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's kind of correct


match 42 {
0 .. 11 => println!("0 ... 10"), //~ERROR: some ranges overlap
0 ... 11 => println!("0 ... 10"), //~NOTE overlaps with this
Copy link
Member

Choose a reason for hiding this comment

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

Same.

(Bound::Included(a), Bound::Included(b)) |
(Bound::Excluded(a), Bound::Excluded(b)) => a.cmp(&b),
(Bound::Unbounded, _) |
(_, Bound::Unbounded) => unimplemented!(),
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment that range patterns need to be bounded? I did not know that and had to check.

@oli-obk oli-obk merged commit 909ef37 into master Jan 31, 2017
@oli-obk oli-obk deleted the excl_range_pat_overlap branch January 31, 2017 11:40
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