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.
This commit is contained in:
parent
c4db4faefa
commit
e78f2e2ac5
72 changed files with 373 additions and 540 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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, \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 } {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue