Skip to content

Commit e4b1842

Browse files
author
Jonathan Turner
committed
Check for overlapping and simplify unit test
1 parent 2ea3ab3 commit e4b1842

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/libsyntax/codemap.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ impl CodeMap {
392392
return None;
393393
}
394394

395-
// ensure these follow the expected order
396-
if sp_lhs.lo <= sp_rhs.lo {
395+
// ensure these follow the expected order and we don't overlap
396+
if (sp_lhs.lo <= sp_rhs.lo) && (sp_lhs.hi <= sp_rhs.lo) {
397397
Some(Span {
398398
lo: cmp::min(sp_lhs.lo, sp_rhs.lo),
399399
hi: cmp::max(sp_lhs.hi, sp_rhs.hi),
@@ -1146,12 +1146,7 @@ mod tests {
11461146
let span1 = span_from_selection(inputtext, selection1);
11471147
let span2 = span_from_selection(inputtext, selection2);
11481148

1149-
if let Some(_) = cm.merge_spans(span1, span2) {
1150-
assert!(false);
1151-
}
1152-
else {
1153-
assert!(true);
1154-
}
1149+
assert!(cm.merge_spans(span1, span2).is_none());
11551150
}
11561151

11571152
/// Returns the span corresponding to the `n`th occurrence of

0 commit comments

Comments
 (0)