@@ -54,7 +54,8 @@ impl IgnoreBlocks {
54
54
pub fn overlaps_ignore ( & self , region : Range < usize > ) -> Option < Range < usize > > {
55
55
for ignore in & self . ignore {
56
56
// See https://stackoverflow.com/questions/3269434.
57
- if ignore. start <= region. end && region. start <= ignore. end {
57
+ // We have strictly < because `end` is not included in our ranges.
58
+ if ignore. start < region. end && region. start < ignore. end {
58
59
return Some ( ignore. clone ( ) ) ;
59
60
}
60
61
}
@@ -77,13 +78,16 @@ fn bodies(s: &str) -> Vec<Ignore<'_>> {
77
78
for range in & cbs. ignore {
78
79
let range = range. clone ( ) ;
79
80
if previous. end != range. start {
81
+ assert ! ( cbs. overlaps_ignore( previous. end..range. start) . is_none( ) ) ;
80
82
bodies. push ( Ignore :: No ( & s[ previous. end ..range. start ] ) ) ;
81
83
}
84
+ assert ! ( cbs. overlaps_ignore( range. clone( ) ) . is_some( ) ) ;
82
85
bodies. push ( Ignore :: Yes ( & s[ range. clone ( ) ] ) ) ;
83
86
previous = range. clone ( ) ;
84
87
}
85
88
if let Some ( range) = cbs. ignore . last ( ) {
86
89
if range. end != s. len ( ) {
90
+ assert ! ( cbs. overlaps_ignore( range. end..s. len( ) ) . is_none( ) ) ;
87
91
bodies. push ( Ignore :: No ( & s[ range. end ..] ) ) ;
88
92
}
89
93
}
@@ -282,3 +286,14 @@ This is an HTML comment.
282
286
] ,
283
287
) ;
284
288
}
289
+
290
+ #[ test]
291
+ fn cbs_13 ( ) {
292
+ assert_eq ! (
293
+ bodies( "<!-- q -->\n @rustbot label +F-trait_upcasting" ) ,
294
+ [
295
+ Ignore :: Yes ( "<!-- q -->\n " ) ,
296
+ Ignore :: No ( "@rustbot label +F-trait_upcasting" )
297
+ ] ,
298
+ ) ;
299
+ }
0 commit comments