diff options
| author | Jonathan Turner <jturner@mozilla.com> | 2016-09-20 15:39:05 -0700 |
|---|---|---|
| committer | Jonathan Turner <jturner@mozilla.com> | 2016-09-20 15:39:05 -0700 |
| commit | e4b18422ad3ee6bf1e749ccd337a25736a78c0bb (patch) | |
| tree | d9bd85afd222bdc3c6ce5f6612f1fed7ba0446f9 /src/libsyntax | |
| parent | 2ea3ab3a9022a93e45c4d50a1c43aec5f56ab4dc (diff) | |
| download | rust-e4b18422ad3ee6bf1e749ccd337a25736a78c0bb.tar.gz rust-e4b18422ad3ee6bf1e749ccd337a25736a78c0bb.zip | |
Check for overlapping and simplify unit test
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index ce15bd89590..6d68ce3646d 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -392,8 +392,8 @@ impl CodeMap { return None; } - // ensure these follow the expected order - if sp_lhs.lo <= sp_rhs.lo { + // ensure these follow the expected order and we don't overlap + if (sp_lhs.lo <= sp_rhs.lo) && (sp_lhs.hi <= sp_rhs.lo) { Some(Span { lo: cmp::min(sp_lhs.lo, sp_rhs.lo), hi: cmp::max(sp_lhs.hi, sp_rhs.hi), @@ -1146,12 +1146,7 @@ mod tests { let span1 = span_from_selection(inputtext, selection1); let span2 = span_from_selection(inputtext, selection2); - if let Some(_) = cm.merge_spans(span1, span2) { - assert!(false); - } - else { - assert!(true); - } + assert!(cm.merge_spans(span1, span2).is_none()); } /// Returns the span corresponding to the `n`th occurrence of |
