@@ -59,23 +59,12 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> copy_map {
59
59
fn visit_fn ( f : ast:: _fn , _tp : [ ast:: ty_param ] , _sp : span , _name : fn_ident ,
60
60
_id : ast:: node_id , sc : scope , v : vt < scope > ) {
61
61
visit:: visit_fn_decl ( f. decl , sc, v) ;
62
- let scope =
63
- alt f. proto {
64
-
65
-
66
-
67
- // Blocks need to obey any restrictions from the enclosing scope.
68
- ast:: proto_block. | ast:: proto_closure. {
69
- sc
70
- }
71
-
72
-
73
-
74
- // Non capturing functions start out fresh.
75
- _ {
76
- @[ ]
77
- }
78
- } ;
62
+ let scope = alt f. proto {
63
+ // Blocks need to obey any restrictions from the enclosing scope.
64
+ ast:: proto_block. | ast:: proto_closure. { sc }
65
+ // Non capturing functions start out fresh.
66
+ _ { @[ ] }
67
+ } ;
79
68
v. visit_block ( f. body , scope, v) ;
80
69
}
81
70
@@ -279,7 +268,7 @@ fn check_alt(cx: ctx, input: @ast::expr, arms: [ast::arm], sc: scope,
279
268
type info = { id : node_id , mutable unsafe: [ ty:: t ] , span : span } ;
280
269
let binding_info: [ info ] = [ ] ;
281
270
for pat in a. pats {
282
- for proot in * pattern_roots ( cx. tcx , root. ds , pat) {
271
+ for proot in * pattern_roots ( cx. tcx , * root. ds , pat) {
283
272
let canon_id = pat_id_map. get ( proot. name ) ;
284
273
// FIXME I wanted to use a block, but that hit a
285
274
// typestate bug.
@@ -327,33 +316,34 @@ fn check_for(cx: ctx, local: @ast::local, seq: @ast::expr, blk: ast::blk,
327
316
sc : scope , v : vt < scope > ) {
328
317
v. visit_expr ( seq, sc, v) ;
329
318
let root = expr_root ( cx. tcx , seq, false ) ;
330
- let unsafe = inner_mut ( root. ds ) ;
331
319
332
320
// If this is a mutable vector, don't allow it to be touched.
333
321
let seq_t = ty:: expr_ty ( cx. tcx , seq) ;
334
- let elt_t ;
322
+ let ext_ds = * root . ds ;
335
323
alt ty:: struct ( cx. tcx , seq_t) {
336
324
ty:: ty_vec ( mt) {
337
- if mt. mut != ast:: imm { unsafe = [ seq_t] ; }
338
- elt_t = mt. ty ;
325
+ if mt. mut != ast:: imm {
326
+ ext_ds += [ @{ mut: true , kind: index, outer_t: seq_t} ] ;
327
+ }
339
328
}
340
- ty :: ty_str . { elt_t = ty :: mk_mach ( cx . tcx , ast :: ty_u8 ) ; }
329
+ _ { }
341
330
}
342
331
let root_var = path_def_id ( cx, root. ex ) ;
343
- let new_sc =
344
- @{ root_var: root_var,
345
- // FIXME reenable when trans knows how to copy for vars
346
- node_id: 0 , // blk.node.id,
347
- ty: elt_t,
348
- span: local. node . pat . span ,
349
- local_id: cx. next_local ,
350
- bindings: ast_util:: pat_binding_ids ( local. node . pat ) ,
351
- unsafe_tys: unsafe ,
352
- depends_on: deps ( sc, root_var) ,
353
- mutable ok: valid,
354
- mutable given_up: false } ;
332
+ let new_sc = * sc;
333
+ for proot in * pattern_roots ( cx. tcx , ext_ds, local. node . pat ) {
334
+ new_sc += [ @{ root_var: root_var,
335
+ node_id: proot. id ,
336
+ ty: ty:: node_id_to_type ( cx. tcx , proot. id ) ,
337
+ span: proot. span ,
338
+ local_id: cx. next_local ,
339
+ bindings: [ proot. id ] ,
340
+ unsafe_tys: inner_mut ( proot. ds ) ,
341
+ depends_on : deps( sc, root_var) ,
342
+ mutable ok: valid,
343
+ mutable given_up: false} ] ;
344
+ }
355
345
register_locals ( cx, local. node . pat ) ;
356
- visit:: visit_block ( blk, @( * sc + [ new_sc] ) , v) ;
346
+ visit:: visit_block ( blk, @new_sc, v) ;
357
347
}
358
348
359
349
fn check_var ( cx : ctx , ex : @ast:: expr , p : ast:: path , id : ast:: node_id ,
@@ -555,7 +545,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
555
545
556
546
type pattern_root = { id : node_id , name : ident, ds : @[ deref ] , span : span } ;
557
547
558
- fn pattern_roots ( tcx : ty:: ctxt , base : @ [ deref ] , pat : @ast:: pat )
548
+ fn pattern_roots ( tcx : ty:: ctxt , base : [ deref ] , pat : @ast:: pat )
559
549
-> @[ pattern_root ] {
560
550
fn walk ( tcx : ty:: ctxt , base : [ deref ] , pat : @ast:: pat ,
561
551
& set: [ pattern_root ] ) {
@@ -587,7 +577,7 @@ fn pattern_roots(tcx: ty::ctxt, base: @[deref], pat: @ast::pat)
587
577
}
588
578
}
589
579
let set = [ ] ;
590
- walk ( tcx, * base, pat, set) ;
580
+ walk ( tcx, base, pat, set) ;
591
581
ret @set;
592
582
}
593
583
0 commit comments