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 | |
| 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')
| -rw-r--r-- | src/libsyntax/ext/deriving.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/check.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/liveness.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/proto.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 33 |
5 files changed, 35 insertions, 17 deletions
diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index 54b123bff2f..76ab21f403b 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -226,7 +226,7 @@ fn create_eq_method(cx: @ext_ctxt, attrs: ~[], generics: ast_util::empty_generics(), self_ty: self_ty, - purity: pure_fn, + purity: impure_fn, decl: fn_decl, body: body_block, id: cx.next_id(), @@ -405,7 +405,7 @@ fn create_iter_bytes_method(cx: @ext_ctxt, attrs: ~[], generics: ast_util::empty_generics(), self_ty: self_ty, - purity: pure_fn, + purity: impure_fn, decl: fn_decl, body: body_block, id: cx.next_id(), diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 30e7e832db1..29c9e86ec62 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -41,7 +41,8 @@ impl proto::visitor<(), (), ()> for @ext_ctxt { fn visit_proto(&self, _proto: protocol, _states: &[()]) { } fn visit_state(&self, state: state, _m: &[()]) { - if state.messages.len() == 0 { + let messages = &*state.messages; + if messages.len() == 0 { self.span_warn( state.span, // use a real span! fmt!("state %s contains no messages, \ diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index 15ba7f95538..c6fdf4d9c1b 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -91,7 +91,7 @@ pub fn analyze(proto: protocol, _cx: @ext_ctxt) { let states = str::connect(self_live.map(|s| copy s.name), ~" "); debug!("protocol %s is unbounded due to loops involving: %s", - proto.name, states); + copy proto.name, states); // Someday this will be configurable with a warning //cx.span_warn(empty_span(), @@ -103,7 +103,7 @@ pub fn analyze(proto: protocol, _cx: @ext_ctxt) { proto.bounded = Some(false); } else { - debug!("protocol %s is bounded. yay!", proto.name); + debug!("protocol %s is bounded. yay!", copy proto.name); proto.bounded = Some(true); } } diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index c9680ac02c9..a47b39a45c8 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -156,7 +156,10 @@ pub impl protocol_ { ~"proto://" + self.name } - fn num_states(&mut self) -> uint { self.states.len() } + fn num_states(&mut self) -> uint { + let states = &mut *self.states; + states.len() + } fn has_ty_params(&mut self) -> bool { for self.states.each |s| { @@ -180,9 +183,10 @@ pub impl protocol_ { +generics: ast::Generics) -> state { let messages = @mut ~[]; + let states = &*self.states; let state = @state_ { - id: self.states.len(), + id: states.len(), name: name, ident: ident, span: self.span, 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 } { |
