diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-16 11:11:31 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-18 17:21:16 -0700 |
| commit | e78f2e2ac577f9c47cd58af52d3bcd496254545d (patch) | |
| tree | f05564837fe02f676458ea86b705709715c44017 /src/libsyntax/ext/tt | |
| parent | c4db4faefaf13ac814f34c2a6cf105b7684de019 (diff) | |
| download | rust-e78f2e2ac577f9c47cd58af52d3bcd496254545d.tar.gz rust-e78f2e2ac577f9c47cd58af52d3bcd496254545d.zip | |
librustc: Make the compiler ignore purity.
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.
There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 908fbd44825..0196ee6d184 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -106,8 +106,9 @@ pub pure fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader { } -pure fn lookup_cur_matched_by_matched(r: @mut TtReader, - start: @named_match) -> @named_match { +pure fn lookup_cur_matched_by_matched(r: &mut TtReader, + start: @named_match) + -> @named_match { pure fn red(+ad: @named_match, idx: &uint) -> @named_match { match *ad { matched_nonterminal(_) => { @@ -117,18 +118,20 @@ pure fn lookup_cur_matched_by_matched(r: @mut TtReader, matched_seq(ref ads, _) => ads[*idx] } } - vec::foldl(start, r.repeat_idx, red) + let r = &mut *r; + let repeat_idx = &r.repeat_idx; + vec::foldl(start, *repeat_idx, red) } -fn lookup_cur_matched(r: @mut TtReader, name: ident) -> @named_match { +fn lookup_cur_matched(r: &mut TtReader, name: ident) -> @named_match { lookup_cur_matched_by_matched(r, r.interpolations.get(&name)) } enum lis { lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str) } -fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { - fn lis_merge(lhs: lis, rhs: lis, r: @mut TtReader) -> lis { +fn lockstep_iter_size(t: token_tree, r: &mut TtReader) -> lis { + fn lis_merge(lhs: lis, rhs: lis, r: &mut TtReader) -> lis { match lhs { lis_unconstrained => copy rhs, lis_contradiction(_) => copy lhs, @@ -148,8 +151,10 @@ fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { } match t { tt_delim(ref tts) | tt_seq(_, ref tts, _, _) => { - vec::foldl(lis_unconstrained, (*tts), |lis, tt| - lis_merge(lis, lockstep_iter_size(*tt, r), r)) + vec::foldl(lis_unconstrained, (*tts), |lis, tt| { + let lis2 = lockstep_iter_size(*tt, r); + lis_merge(lis, lis2, r) + }) } tt_tok(*) => lis_unconstrained, tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) { @@ -160,12 +165,20 @@ fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { } -pub fn tt_next_token(r: @mut TtReader) -> TokenAndSpan { +pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { let ret_val = TokenAndSpan { tok: copy r.cur_tok, sp: r.cur_span, }; - while r.cur.idx >= r.cur.readme.len() { + loop { + { + let cur = &mut *r.cur; + let readme = &mut *cur.readme; + if cur.idx < readme.len() { + break; + } + } + /* done with this set; pop or repeat? */ if ! r.cur.dotdotdoted || { *r.repeat_idx.last() == *r.repeat_len.last() - 1 } { |
