This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -1761,10 +1761,17 @@ where
1761
1761
match value {
1762
1762
Kind :: Start ( _, r) => started. push ( r) ,
1763
1763
Kind :: End ( _, er) => {
1764
- if let Some ( sr) = started. pop ( ) {
1765
- if sr != er {
1766
- return Some ( ( er, sr) ) ;
1764
+ let mut overlap = None ;
1765
+
1766
+ while let Some ( sr) = started. pop ( ) {
1767
+ if sr == er {
1768
+ break ;
1767
1769
}
1770
+ overlap = Some ( sr) ;
1771
+ }
1772
+
1773
+ if let Some ( sr) = overlap {
1774
+ return Some ( ( er, sr) ) ;
1768
1775
}
1769
1776
} ,
1770
1777
}
Original file line number Diff line number Diff line change @@ -116,6 +116,15 @@ fn overlapping() {
116
116
_ => ( ) ,
117
117
}
118
118
119
+ // Only warn about the first if there are multiple overlaps
120
+ match 42u128 {
121
+ 0 ..=0x0000_0000_0000_00ff => ( ) ,
122
+ 0 ..=0x0000_0000_0000_ffff => ( ) ,
123
+ 0 ..=0x0000_0000_ffff_ffff => ( ) ,
124
+ 0 ..=0xffff_ffff_ffff_ffff => ( ) ,
125
+ _ => ( ) ,
126
+ }
127
+
119
128
if let None = Some ( 42 ) {
120
129
// nothing
121
130
} else if let None = Some ( 42 ) {
Original file line number Diff line number Diff line change @@ -83,5 +83,17 @@ note: overlaps with this
83
83
LL | 21..=40 => (),
84
84
| ^^^^^^^
85
85
86
- error: aborting due to 7 previous errors
86
+ error: some ranges overlap
87
+ --> $DIR/match_overlapping_arm.rs:121:9
88
+ |
89
+ LL | 0..=0x0000_0000_0000_00ff => (),
90
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
91
+ |
92
+ note: overlaps with this
93
+ --> $DIR/match_overlapping_arm.rs:122:9
94
+ |
95
+ LL | 0..=0x0000_0000_0000_ffff => (),
96
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
97
+
98
+ error: aborting due to 8 previous errors
87
99
You can’t perform that action at this time.
0 commit comments