@@ -22,7 +22,7 @@ type invalid = {reason: invalid_reason,
22
22
node_id : node_id ,
23
23
sp : span , path: @ast:: path } ;
24
24
25
- enum unsafe_ty { contains( ty:: t ) , mut_contains ( ty:: t ) , }
25
+ enum unsafe_ty { contains( ty:: t ) , mutbl_contains ( ty:: t ) , }
26
26
27
27
type binding = @{ node_id : node_id ,
28
28
span : span ,
@@ -183,9 +183,9 @@ fn add_bindings_for_let(cx: ctx, &bs: [binding], loc: @ast::local) {
183
183
err ( cx, loc. span , "a reference binding can't be \
184
184
rooted in a temporary") ;
185
185
}
186
- for proot in pattern_roots ( cx. tcx , root. mut , loc. node . pat ) {
186
+ for proot in pattern_roots ( cx. tcx , root. mutbl , loc. node . pat ) {
187
187
let bnd = mk_binding ( cx, proot. id , proot. span , root_var,
188
- unsafe_set ( proot. mut ) ) ;
188
+ unsafe_set ( proot. mutbl ) ) ;
189
189
// Don't implicitly copy explicit references
190
190
bnd. copied = not_allowed;
191
191
bs += [ bnd] ;
@@ -228,7 +228,7 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
228
228
let arg = args[ i] ;
229
229
let root = expr_root ( cx, arg, false ) ;
230
230
alt ty:: resolved_mode ( cx. tcx , arg_t. mode ) {
231
- ast:: by_mut_ref {
231
+ ast:: by_mutbl_ref {
232
232
alt path_def( cx, arg) {
233
233
some ( def) {
234
234
let dnum = ast_util:: def_id_of_def ( def) . node ;
@@ -242,14 +242,14 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
242
242
let root_var = path_def_id ( cx, root. ex ) ;
243
243
let arg_copied = alt ty:: resolved_mode ( cx. tcx , arg_t. mode ) {
244
244
ast:: by_move | ast:: by_copy { copied }
245
- ast:: by_mut_ref { not_allowed }
245
+ ast:: by_mutbl_ref { not_allowed }
246
246
ast:: by_ref | ast:: by_val { not_copied }
247
247
} ;
248
248
bindings += [ @{ node_id: arg. id ,
249
249
span: arg. span ,
250
250
root_var: root_var,
251
251
local_id: 0 u,
252
- unsafe_tys: unsafe_set ( root. mut ) ,
252
+ unsafe_tys: unsafe_set ( root. mutbl ) ,
253
253
mutable copied: arg_copied} ] ;
254
254
i += 1 u;
255
255
}
@@ -285,7 +285,7 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
285
285
let i = 0 u;
286
286
for arg_t: ty:: arg in arg_ts {
287
287
let mut_alias =
288
- ( ast:: by_mut_ref == ty:: arg_mode ( cx. tcx , arg_t) ) ;
288
+ ( ast:: by_mutbl_ref == ty:: arg_mode ( cx. tcx , arg_t) ) ;
289
289
if i != j &&
290
290
ty_can_unsafely_include ( cx, unsafe_ty, arg_t. ty ,
291
291
mut_alias) &&
@@ -339,14 +339,14 @@ fn check_alt(cx: ctx, input: @ast::expr, arms: [ast::arm], sc: scope,
339
339
span : span } ;
340
340
let binding_info: [ info ] = [ ] ;
341
341
for pat in a. pats {
342
- for proot in pattern_roots ( cx. tcx , root. mut , pat) {
342
+ for proot in pattern_roots ( cx. tcx , root. mutbl , pat) {
343
343
let canon_id = pat_id_map. get ( proot. name ) ;
344
344
alt vec:: find ( binding_info, { |x| x. id == canon_id} ) {
345
- some ( s) { s. unsafe_tys += unsafe_set ( proot. mut ) ; }
345
+ some ( s) { s. unsafe_tys += unsafe_set ( proot. mutbl ) ; }
346
346
none {
347
347
binding_info += [
348
348
{ id: canon_id,
349
- mutable unsafe_tys: unsafe_set ( proot. mut ) ,
349
+ mutable unsafe_tys: unsafe_set ( proot. mutbl ) ,
350
350
span: proot. span } ] ;
351
351
}
352
352
}
@@ -369,20 +369,20 @@ fn check_for(cx: ctx, local: @ast::local, seq: @ast::expr, blk: ast::blk,
369
369
370
370
// If this is a mutable vector, don't allow it to be touched.
371
371
let seq_t = ty:: expr_ty ( cx. tcx , seq) ;
372
- let cur_mut = root. mut ;
372
+ let cur_mutbl = root. mutbl ;
373
373
alt ty:: get ( seq_t) . struct {
374
374
ty:: ty_vec ( mt) {
375
- if mt. mut != ast:: imm {
376
- cur_mut = some ( contains ( seq_t) ) ;
375
+ if mt. mutbl != ast:: m_imm {
376
+ cur_mutbl = some ( contains ( seq_t) ) ;
377
377
}
378
378
}
379
379
_ { }
380
380
}
381
381
let root_var = path_def_id ( cx, root. ex ) ;
382
382
let new_bs = sc. bs ;
383
- for proot in pattern_roots ( cx. tcx , cur_mut , local. node . pat ) {
383
+ for proot in pattern_roots ( cx. tcx , cur_mutbl , local. node . pat ) {
384
384
new_bs += [ mk_binding ( cx, proot. id , proot. span , root_var,
385
- unsafe_set ( proot. mut ) ) ] ;
385
+ unsafe_set ( proot. mutbl ) ) ] ;
386
386
}
387
387
visit:: visit_block ( blk, { bs: new_bs with sc} , v) ;
388
388
}
@@ -493,36 +493,36 @@ fn path_def_id(cx: ctx, ex: @ast::expr) -> option<ast::node_id> {
493
493
}
494
494
495
495
fn ty_can_unsafely_include ( cx : ctx , needle : unsafe_ty , haystack : ty:: t ,
496
- mut : bool ) -> bool {
497
- fn get_mut ( cur : bool , mt : ty:: mt ) -> bool {
498
- ret cur || mt. mut != ast:: imm ;
496
+ mutbl : bool ) -> bool {
497
+ fn get_mutbl ( cur : bool , mt : ty:: mt ) -> bool {
498
+ ret cur || mt. mutbl != ast:: m_imm ;
499
499
}
500
- fn helper ( tcx : ty:: ctxt , needle : unsafe_ty , haystack : ty:: t , mut : bool )
500
+ fn helper ( tcx : ty:: ctxt , needle : unsafe_ty , haystack : ty:: t , mutbl : bool )
501
501
-> bool {
502
502
if alt needle {
503
503
contains ( ty) { ty == haystack }
504
- mut_contains ( ty) { mut && ty == haystack }
504
+ mutbl_contains ( ty) { mutbl && ty == haystack }
505
505
} { ret true ; }
506
506
alt ty:: get ( haystack) . struct {
507
507
ty:: ty_enum ( _, ts) {
508
508
for t: ty:: t in ts {
509
- if helper ( tcx, needle, t, mut ) { ret true ; }
509
+ if helper ( tcx, needle, t, mutbl ) { ret true ; }
510
510
}
511
511
ret false;
512
512
}
513
513
ty:: ty_box ( mt) | ty:: ty_ptr ( mt) | ty:: ty_uniq ( mt) {
514
- ret helper ( tcx, needle, mt. ty , get_mut ( mut , mt) ) ;
514
+ ret helper ( tcx, needle, mt. ty , get_mutbl ( mutbl , mt) ) ;
515
515
}
516
516
ty:: ty_rec ( fields) {
517
517
for f: ty:: field in fields {
518
- if helper ( tcx, needle, f. mt . ty , get_mut ( mut , f. mt ) ) {
518
+ if helper ( tcx, needle, f. mt . ty , get_mutbl ( mutbl , f. mt ) ) {
519
519
ret true ;
520
520
}
521
521
}
522
522
ret false;
523
523
}
524
524
ty:: ty_tup ( ts) {
525
- for t in ts { if helper ( tcx, needle, t, mut ) { ret true ; } }
525
+ for t in ts { if helper ( tcx, needle, t, mutbl ) { ret true ; } }
526
526
ret false;
527
527
}
528
528
ty:: ty_fn ( { proto: ast:: proto_bare, _} ) { ret false ; }
@@ -532,11 +532,11 @@ fn ty_can_unsafely_include(cx: ctx, needle: unsafe_ty, haystack: ty::t,
532
532
// treated as opaque downstream, and is thus safe unless we
533
533
// saw mutable fields, in which case the whole thing can be
534
534
// overwritten.
535
- ty:: ty_param ( _, _) { ret mut ; }
535
+ ty:: ty_param ( _, _) { ret mutbl ; }
536
536
_ { ret false; }
537
537
}
538
538
}
539
- ret helper( cx. tcx , needle, haystack, mut ) ;
539
+ ret helper( cx. tcx , needle, haystack, mutbl ) ;
540
540
}
541
541
542
542
fn def_is_local ( d : ast:: def ) -> bool {
@@ -589,66 +589,66 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
589
589
590
590
type pattern_root = { id: node_id,
591
591
name: ident,
592
- mut : option<unsafe_ty>,
592
+ mutbl : option<unsafe_ty>,
593
593
span: span} ;
594
594
595
- fn pattern_roots ( tcx : ty:: ctxt , mut : option < unsafe_ty > , pat : @ast:: pat )
595
+ fn pattern_roots ( tcx : ty:: ctxt , mutbl : option < unsafe_ty > , pat : @ast:: pat )
596
596
-> [ pattern_root ] {
597
- fn walk ( tcx : ty:: ctxt , mut : option < unsafe_ty > , pat : @ast:: pat ,
597
+ fn walk ( tcx : ty:: ctxt , mutbl : option < unsafe_ty > , pat : @ast:: pat ,
598
598
& set: [ pattern_root ] ) {
599
599
alt normalize_pat ( tcx, pat) . node {
600
600
ast:: pat_wild | ast:: pat_lit ( _) | ast:: pat_range ( _, _) { }
601
601
ast:: pat_ident ( nm, sub) {
602
- set += [ { id: pat. id , name: path_to_ident ( nm) , mut : mut ,
602
+ set += [ { id: pat. id , name: path_to_ident ( nm) , mutbl : mutbl ,
603
603
span: pat. span } ] ;
604
- alt sub { some( p) { walk ( tcx, mut , p, set) ; } _ { } }
604
+ alt sub { some( p) { walk ( tcx, mutbl , p, set) ; } _ { } }
605
605
}
606
606
ast:: pat_enum ( _, ps) | ast:: pat_tup ( ps) {
607
- for p in ps { walk ( tcx, mut , p, set) ; }
607
+ for p in ps { walk ( tcx, mutbl , p, set) ; }
608
608
}
609
609
ast:: pat_rec ( fs, _) {
610
610
let ty = ty:: node_id_to_type ( tcx, pat. id ) ;
611
611
for f in fs {
612
- let m = ty:: get_field ( ty, f. ident ) . mt . mut != ast:: imm ,
613
- c = if m { some ( contains ( ty) ) } else { mut } ;
612
+ let m = ty:: get_field ( ty, f. ident ) . mt . mutbl != ast:: m_imm ,
613
+ c = if m { some ( contains ( ty) ) } else { mutbl } ;
614
614
walk ( tcx, c, f. pat , set) ;
615
615
}
616
616
}
617
617
ast:: pat_box ( p) {
618
618
let ty = ty:: node_id_to_type ( tcx, pat. id ) ;
619
619
let m = alt ty:: get ( ty) . struct {
620
- ty:: ty_box ( mt) { mt. mut != ast:: imm }
620
+ ty:: ty_box ( mt) { mt. mutbl != ast:: m_imm }
621
621
_ { tcx. sess . span_bug ( pat. span , "box pat has non-box type" ) ; }
622
622
} ,
623
- c = if m { some ( contains ( ty) ) } else { mut } ;
623
+ c = if m { some ( contains ( ty) ) } else { mutbl } ;
624
624
walk ( tcx, c, p, set) ;
625
625
}
626
626
ast:: pat_uniq ( p) {
627
627
let ty = ty:: node_id_to_type ( tcx, pat. id ) ;
628
628
let m = alt ty:: get ( ty) . struct {
629
- ty:: ty_uniq ( mt) { mt. mut != ast:: imm }
629
+ ty:: ty_uniq ( mt) { mt. mutbl != ast:: m_imm }
630
630
_ { tcx. sess . span_bug ( pat. span , "uniq pat has non-uniq type" ) ; }
631
631
} ,
632
- c = if m { some ( contains ( ty) ) } else { mut } ;
632
+ c = if m { some ( contains ( ty) ) } else { mutbl } ;
633
633
walk ( tcx, c, p, set) ;
634
634
}
635
635
}
636
636
}
637
637
let set = [ ] ;
638
- walk ( tcx, mut , pat, set) ;
638
+ walk ( tcx, mutbl , pat, set) ;
639
639
ret set;
640
640
}
641
641
642
- // Wraps the expr_root in mut .rs to also handle roots that exist through
642
+ // Wraps the expr_root in mutbl .rs to also handle roots that exist through
643
643
// return-by-reference
644
644
fn expr_root ( cx : ctx , ex : @ast:: expr , autoderef : bool )
645
- -> { ex : @ast:: expr , mut : option < unsafe_ty > } {
646
- let base_root = mut :: expr_root ( cx. tcx , ex, autoderef) ;
645
+ -> { ex : @ast:: expr , mutbl : option < unsafe_ty > } {
646
+ let base_root = mutbl :: expr_root ( cx. tcx , ex, autoderef) ;
647
647
let unsafe_ty = none;
648
648
for d in * base_root. ds {
649
- if d. mut { unsafe_ty = some ( contains ( d. outer_t ) ) ; break ; }
649
+ if d. mutbl { unsafe_ty = some ( contains ( d. outer_t ) ) ; break ; }
650
650
}
651
- ret { ex : base_root. ex , mut : unsafe_ty} ;
651
+ ret { ex : base_root. ex , mutbl : unsafe_ty} ;
652
652
}
653
653
654
654
fn unsafe_set ( from : option < unsafe_ty > ) -> [ unsafe_ty ] {
0 commit comments