More complete fix to #3162 (borrowck bug related to access to rec fields)

This commit is contained in:
Niko Matsakis 2012-08-23 14:46:59 -07:00
parent 83e7c869bd
commit a08f3a7d4d
9 changed files with 51 additions and 39 deletions

View file

@ -326,19 +326,8 @@ impl check_loan_ctxt {
// even to data owned by the current stack frame. This is
// because that aliasable data might have been located on
// the current stack frame, we don't know.
match cmt.lp {
some(@lp_local(*)) | some(@lp_arg(*)) => {
// it's ok to mutate a local variable, as it is either
// lent our or not. The problem arises when you have
// some subcomponent that might have been lent out
// through an alias on the condition that you ensure
// purity.
}
none | some(@lp_comp(*)) | some(@lp_deref(*)) => {
self.report_purity_error(
pc, ex.span, at.ing_form(self.bccx.cmt_to_str(cmt)));
}
}
self.report_purity_error(
pc, ex.span, at.ing_form(self.bccx.cmt_to_str(cmt)));
}
some(pc_pure_fn) => {
if cmt.lp.is_none() {

View file

@ -2065,7 +2065,7 @@ struct Resolver {
str_of(name)));
return Failed;
}
ModuleDef(module_) => {
ModuleDef(copy module_) => {
search_module = module_;
}
}

View file

@ -116,10 +116,13 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
}
fn type_needs(cx: ctx, use: uint, ty: ty::t) {
let mut done = true;
// Optimization -- don't descend type if all params already have this use
for vec::each(cx.uses) |u| { if u & use != use { done = false } }
if !done { type_needs_inner(cx, use, ty, @nil); }
for vec::each_mut(cx.uses) |u| {
if *u & use != use {
type_needs_inner(cx, use, ty, @nil);
return;
}
}
}
fn type_needs_inner(cx: ctx, use: uint, ty: ty::t,