Skip to content

Commit 7f7ffd7

Browse files
committed
---
yaml --- r: 16317 b: refs/heads/try c: 08520a1 h: refs/heads/master i: 16315: c394fb1 v: v3
1 parent 68b27a0 commit 7f7ffd7

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: d9db4f02a4092009a29fa4b2f0be0438856aeb36
5+
refs/heads/try: 08520a16978264eb599d4df843794126656f78d3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/borrowck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ import util::common::indenter;
164164
import ast_util::op_expr_callee_id;
165165
import ty::to_str;
166166
import driver::session::session;
167+
import dvec::{dvec, extensions};
167168

168169
export check_crate, root_map, mutbl_map;
169170

@@ -298,7 +299,7 @@ type loan = {lp: @loan_path, cmt: cmt, mutbl: ast::mutability};
298299

299300
// maps computed by `gather_loans` that are then used by `check_loans`
300301
type req_maps = {
301-
req_loan_map: hashmap<ast::node_id, @mut [@const [loan]]>,
302+
req_loan_map: hashmap<ast::node_id, @dvec<@dvec<loan>>>,
302303
pure_map: hashmap<ast::node_id, bckerr>
303304
};
304305

branches/try/src/rustc/middle/borrowck/check_loans.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// 3. assignments do not affect things loaned out as immutable
88
// 4. moves to dnot affect things loaned out in any way
99

10+
import dvec::{dvec, extensions};
1011
import categorization::public_methods;
1112

1213
export check_loans;
@@ -22,7 +23,7 @@ enum check_loan_ctxt = @{
2223
// we are in a ctor, we track the self id
2324
mut in_ctor: bool,
2425
mut declared_purity: ast::purity,
25-
mut fn_args: [ast::node_id]
26+
mut fn_args: @[ast::node_id]
2627
};
2728

2829
// if we are enforcing purity, why are we doing so?
@@ -44,7 +45,7 @@ fn check_loans(bccx: borrowck_ctxt,
4445
reported: int_hash(),
4546
mut in_ctor: false,
4647
mut declared_purity: ast::impure_fn,
47-
mut fn_args: []});
48+
mut fn_args: @[]});
4849
let vt = visit::mk_vt(@{visit_expr: check_loans_in_expr,
4950
visit_block: check_loans_in_block,
5051
visit_fn: check_loans_in_fn
@@ -179,7 +180,7 @@ impl methods for check_loan_ctxt {
179180
let did = ast_util::def_id_of_def(def);
180181
let is_fn_arg =
181182
did.crate == ast::local_crate &&
182-
self.fn_args.contains(did.node);
183+
(*self.fn_args).contains(did.node);
183184
if is_fn_arg { ret; } // case (a) above
184185
}
185186
ast::expr_fn_block(*) | ast::expr_fn(*) |
@@ -225,7 +226,8 @@ impl methods for check_loan_ctxt {
225226
ast::expr_path(_) {
226227
let def = self.tcx().def_map.get(expr.id);
227228
let did = ast_util::def_id_of_def(def);
228-
did.crate == ast::local_crate && self.fn_args.contains(did.node)
229+
did.crate == ast::local_crate &&
230+
(*self.fn_args).contains(did.node)
229231
}
230232
ast::expr_fn_block(*) | ast::expr_fn(*) {
231233
self.is_stack_closure(expr.id)
@@ -484,7 +486,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
484486
sp: span, id: ast::node_id, &&self: check_loan_ctxt,
485487
visitor: visit::vt<check_loan_ctxt>) {
486488

487-
#debug["purity on entry=%?", self.declared_purity];
489+
#debug["purity on entry=%?", copy self.declared_purity];
488490
save_and_restore(self.in_ctor) {||
489491
save_and_restore(self.declared_purity) {||
490492
save_and_restore(self.fn_args) {||
@@ -500,7 +502,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
500502
visit::fk_ctor(*) {
501503
self.in_ctor = true;
502504
self.declared_purity = decl.purity;
503-
self.fn_args = decl.inputs.map({|i| i.id});
505+
self.fn_args = @decl.inputs.map({|i| i.id});
504506
}
505507
visit::fk_anon(*) |
506508
visit::fk_fn_block(*) if is_stack_closure {
@@ -512,15 +514,15 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
512514
visit::fk_res(*) | visit::fk_dtor(*) {
513515
self.in_ctor = false;
514516
self.declared_purity = decl.purity;
515-
self.fn_args = decl.inputs.map({|i| i.id});
517+
self.fn_args = @decl.inputs.map({|i| i.id});
516518
}
517519
}
518520

519521
visit::visit_fn(fk, decl, body, sp, id, self, visitor);
520522
}
521523
}
522524
}
523-
#debug["purity on exit=%?", self.declared_purity];
525+
#debug["purity on exit=%?", copy self.declared_purity];
524526
}
525527

526528
fn check_loans_in_expr(expr: @ast::expr,

branches/try/src/rustc/middle/borrowck/gather_loans.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,14 @@ impl methods for gather_loan_ctxt {
273273
}
274274
}
275275

276-
fn add_loans(scope_id: ast::node_id, loans: @const [loan]) {
276+
fn add_loans(scope_id: ast::node_id, loans: @dvec<loan>) {
277277
alt self.req_maps.req_loan_map.find(scope_id) {
278278
some(l) {
279-
*l += [loans];
279+
(*l).push(loans);
280280
}
281281
none {
282-
self.req_maps.req_loan_map.insert(scope_id, @mut [loans]);
282+
self.req_maps.req_loan_map.insert(
283+
scope_id, @dvec::from_vec([mut loans]));
283284
}
284285
}
285286
}

branches/try/src/rustc/middle/borrowck/loan.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
export public_methods;
66

77
impl public_methods for borrowck_ctxt {
8-
fn loan(cmt: cmt, mutbl: ast::mutability) -> @const [loan] {
9-
let lc = @{bccx: self, loans: @mut []};
8+
fn loan(cmt: cmt, mutbl: ast::mutability) -> @dvec<loan> {
9+
let lc = @{bccx: self, loans: @dvec()};
1010
lc.loan(cmt, mutbl);
1111
ret lc.loans;
1212
}
1313
}
1414

1515
type loan_ctxt = @{
1616
bccx: borrowck_ctxt,
17-
loans: @mut [loan]
17+
loans: @dvec<loan>
1818
};
1919

2020
impl loan_methods for loan_ctxt {
@@ -23,9 +23,9 @@ impl loan_methods for loan_ctxt {
2323
// Note: all cmt's that we deal with will have a non-none lp, because
2424
// the entry point into this routine, `borrowck_ctxt::loan()`, rejects
2525
// any cmt with a none-lp.
26-
*self.loans += [{lp:option::get(cmt.lp),
27-
cmt:cmt,
28-
mutbl:mutbl}];
26+
(*self.loans).push({lp:option::get(cmt.lp),
27+
cmt:cmt,
28+
mutbl:mutbl});
2929
}
3030

3131
fn loan(cmt: cmt, req_mutbl: ast::mutability) {

0 commit comments

Comments
 (0)