@@ -97,7 +97,7 @@ fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind {
97
97
98
98
impl public_methods for borrowck_ctxt {
99
99
fn cat_borrow_of_expr ( expr : @ast:: expr ) -> cmt {
100
- // a borrowed expression must be either an @, ~, or a vec/@, vec/~
100
+ // a borrowed expression must be either an @, ~, or a @vec, ~vec
101
101
let expr_ty = ty:: expr_ty ( self . tcx , expr) ;
102
102
alt ty:: get ( expr_ty) . struct {
103
103
ty:: ty_evec ( * ) | ty:: ty_estr ( * ) {
@@ -109,6 +109,12 @@ impl public_methods for borrowck_ctxt {
109
109
self . cat_deref ( expr, cmt, 0 u, true ) . get ( )
110
110
}
111
111
112
+ /*
113
+ ty::ty_fn({proto, _}) {
114
+ self.cat_call(expr, expr, proto)
115
+ }
116
+ */
117
+
112
118
_ {
113
119
self. tcx . sess . span_bug (
114
120
expr. span ,
@@ -341,9 +347,20 @@ impl public_methods for borrowck_ctxt {
341
347
}
342
348
} ;
343
349
350
+ // for unique ptrs, we inherit mutability from the
351
+ // owning reference.
352
+ let m = alt ptr {
353
+ uniq_ptr => {
354
+ self . inherited_mutability ( base_cmt. mutbl , mt. mutbl )
355
+ }
356
+ gc_ptr | region_ptr | unsafe_ptr => {
357
+ mt. mutbl
358
+ }
359
+ } ;
360
+
344
361
@{ id: node. id ( ) , span: node. span ( ) ,
345
362
cat: cat_deref ( base_cmt, derefs, ptr) , lp: lp,
346
- mutbl: mt . mutbl , ty: mt. ty }
363
+ mutbl: m , ty: mt. ty }
347
364
}
348
365
349
366
deref_comp ( comp) {
@@ -379,27 +396,38 @@ impl public_methods for borrowck_ctxt {
379
396
_ => { none}
380
397
} ;
381
398
382
- // (b) the deref is explicit in the resulting cmt
399
+ // (b) for unique ptrs, we inherit mutability from the
400
+ // owning reference.
401
+ let m = alt ptr {
402
+ uniq_ptr => {
403
+ self . inherited_mutability ( base_cmt. mutbl , mt. mutbl )
404
+ }
405
+ gc_ptr | region_ptr | unsafe_ptr => {
406
+ mt. mutbl
407
+ }
408
+ } ;
409
+
410
+ // (c) the deref is explicit in the resulting cmt
383
411
let deref_cmt = @{ id: expr. id , span: expr. span ,
384
412
cat: cat_deref ( base_cmt, 0 u, ptr) , lp: deref_lp,
385
- mutbl: m_imm , ty: mt. ty } ;
413
+ mutbl: m , ty: mt. ty } ;
386
414
387
- comp ( expr, deref_cmt, base_cmt. ty , mt )
415
+ comp ( expr, deref_cmt, base_cmt. ty , m , mt . ty )
388
416
}
389
417
390
418
deref_comp ( _) {
391
419
// fixed-length vectors have no deref
392
- comp ( expr, base_cmt, base_cmt. ty , mt)
420
+ comp ( expr, base_cmt, base_cmt. ty , mt. mutbl , mt . ty )
393
421
}
394
422
} ;
395
423
396
424
fn comp ( expr : @ast:: expr , of_cmt : cmt ,
397
- vect : ty:: t , mt : ty:: mt ) -> cmt {
398
- let comp = comp_index ( vect, mt . mutbl ) ;
425
+ vect : ty:: t , mutbl : ast :: mutability , ty : ty :: t ) -> cmt {
426
+ let comp = comp_index ( vect, mutbl) ;
399
427
let index_lp = of_cmt. lp . map ( |lp| @lp_comp ( lp, comp) ) ;
400
428
@{ id: expr. id , span: expr. span ,
401
429
cat: cat_comp ( of_cmt, comp) , lp: index_lp,
402
- mutbl: mt . mutbl , ty: mt . ty }
430
+ mutbl: mutbl, ty: ty}
403
431
}
404
432
}
405
433
0 commit comments