diff options
| author | Kevin Atkinson <kevina@cs.utah.edu> | 2012-03-06 18:07:10 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-03-13 07:40:41 -0400 |
| commit | 15985277b98e53014b52c1e243eefcfb0335089f (patch) | |
| tree | f3be9f89776c993262ee7f1bc4981e7afad25af2 /src/rustc/syntax/ext | |
| parent | 6f5853f5a1767e0c418fd5f348a795b76d701b3e (diff) | |
Fix Issue #1926 by sorting the gather list.
Diffstat (limited to 'src/rustc/syntax/ext')
| -rw-r--r-- | src/rustc/syntax/ext/qquote.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rustc/syntax/ext/qquote.rs b/src/rustc/syntax/ext/qquote.rs index afcae2ff690..f93a4019c31 100644 --- a/src/rustc/syntax/ext/qquote.rs +++ b/src/rustc/syntax/ext/qquote.rs @@ -103,6 +103,9 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt with *default_visitor()}; let cx = @{lo:lo, mutable gather: []}; node.visit(cx, mk_vt(v)); + // FIXME: Maybe this is an overkill (merge_sort), it might be better + // to just keep the gather array in sorted order ... + cx.gather = std::sort::merge_sort({|a,b| a.lo < b.lo}, copy cx.gather); ret cx; } @@ -200,9 +203,11 @@ fn finish<T: qq_helper> let qcx = gather_anti_quotes(sp.lo, node); let cx = qcx; - // assert that the vector is sorted by position: uint::range(1u, vec::len(cx.gather)) {|i| assert cx.gather[i-1u].lo < cx.gather[i].lo; + // ^^ check that the vector is sorted + assert cx.gather[i-1u].hi <= cx.gather[i].lo; + // ^^ check that the spans are non-overlapping } let str2 = ""; |
