@@ -84,10 +84,10 @@ pub struct CopiedUpvar {
84
84
// different kinds of pointers:
85
85
#[ deriving( Eq ) ]
86
86
pub enum ptr_kind {
87
- uniq_ptr( ast :: mutability ) ,
87
+ uniq_ptr,
88
88
gc_ptr( ast:: mutability ) ,
89
89
region_ptr( ast:: mutability , ty:: Region ) ,
90
- unsafe_ptr
90
+ unsafe_ptr( ast :: mutability )
91
91
}
92
92
93
93
// We use the term "interior" to mean "something reachable from the
@@ -156,39 +156,45 @@ pub enum deref_kind {
156
156
// pointer adjustment).
157
157
pub fn opt_deref_kind ( t : ty:: t ) -> Option < deref_kind > {
158
158
match ty:: get ( t) . sty {
159
- ty:: ty_uniq( mt) => {
160
- Some ( deref_ptr ( uniq_ptr ( mt. mutbl ) ) )
161
- }
162
-
159
+ ty:: ty_uniq( _) |
160
+ ty:: ty_trait( _, _, ty:: UniqTraitStore , _, _) |
163
161
ty:: ty_evec( _, ty:: vstore_uniq) |
164
162
ty:: ty_estr( ty:: vstore_uniq) |
165
163
ty:: ty_closure( ty:: ClosureTy { sigil : ast:: OwnedSigil , _} ) => {
166
- Some ( deref_ptr ( uniq_ptr ( m_imm ) ) )
164
+ Some ( deref_ptr ( uniq_ptr) )
167
165
}
168
166
169
167
ty:: ty_rptr( r, mt) |
170
168
ty:: ty_evec( mt, ty:: vstore_slice( r) ) => {
171
169
Some ( deref_ptr ( region_ptr ( mt. mutbl , r) ) )
172
170
}
173
171
172
+ ty:: ty_trait( _, _, ty:: RegionTraitStore ( r) , m, _) => {
173
+ Some ( deref_ptr ( region_ptr ( m, r) ) )
174
+ }
175
+
174
176
ty:: ty_estr( ty:: vstore_slice( r) ) |
175
177
ty:: ty_closure( ty:: ClosureTy { sigil : ast:: BorrowedSigil ,
176
178
region : r, _} ) => {
177
179
Some ( deref_ptr ( region_ptr ( ast:: m_imm, r) ) )
178
180
}
179
181
180
- ty:: ty_box( mt) |
181
- ty:: ty_evec( mt, ty:: vstore_box) => {
182
+ ty:: ty_box( ref mt) |
183
+ ty:: ty_evec( ref mt, ty:: vstore_box) => {
182
184
Some ( deref_ptr ( gc_ptr ( mt. mutbl ) ) )
183
185
}
184
186
187
+ ty:: ty_trait( _, _, ty:: BoxTraitStore , m, _) => {
188
+ Some ( deref_ptr ( gc_ptr ( m) ) )
189
+ }
190
+
185
191
ty:: ty_estr( ty:: vstore_box) |
186
192
ty:: ty_closure( ty:: ClosureTy { sigil : ast:: ManagedSigil , _} ) => {
187
193
Some ( deref_ptr ( gc_ptr ( ast:: m_imm) ) )
188
194
}
189
195
190
- ty:: ty_ptr( * ) => {
191
- Some ( deref_ptr ( unsafe_ptr) )
196
+ ty:: ty_ptr( ref mt ) => {
197
+ Some ( deref_ptr ( unsafe_ptr ( mt . mutbl ) ) )
192
198
}
193
199
194
200
ty:: ty_enum( * ) |
@@ -631,20 +637,19 @@ impl mem_categorization_ctxt {
631
637
}
632
638
}
633
639
634
- pub fn cat_deref_fn < N : ast_node > ( & self ,
635
- node : N ,
636
- base_cmt : cmt ,
637
- deref_cnt : uint )
638
- -> cmt {
640
+ pub fn cat_deref_fn_or_obj < N : ast_node > ( & self ,
641
+ node : N ,
642
+ base_cmt : cmt ,
643
+ deref_cnt : uint )
644
+ -> cmt {
639
645
// Bit of a hack: the "dereference" of a function pointer like
640
646
// `@fn()` is a mere logical concept. We interpret it as
641
647
// dereferencing the environment pointer; of course, we don't
642
648
// know what type lies at the other end, so we just call it
643
649
// `()` (the empty tuple).
644
650
645
- let mt = ty:: mt { ty : ty:: mk_tup ( self . tcx , ~[ ] ) ,
646
- mutbl : m_imm} ;
647
- return self . cat_deref_common ( node, base_cmt, deref_cnt, mt) ;
651
+ let opaque_ty = ty:: mk_tup ( self . tcx , ~[ ] ) ;
652
+ return self . cat_deref_common ( node, base_cmt, deref_cnt, opaque_ty) ;
648
653
}
649
654
650
655
pub fn cat_deref < N : ast_node > ( & self ,
@@ -662,25 +667,25 @@ impl mem_categorization_ctxt {
662
667
}
663
668
} ;
664
669
665
- return self . cat_deref_common ( node, base_cmt, deref_cnt, mt) ;
670
+ return self . cat_deref_common ( node, base_cmt, deref_cnt, mt. ty ) ;
666
671
}
667
672
668
673
pub fn cat_deref_common < N : ast_node > ( & self ,
669
674
node : N ,
670
675
base_cmt : cmt ,
671
676
deref_cnt : uint ,
672
- mt : ty:: mt )
677
+ deref_ty : ty:: t )
673
678
-> cmt {
674
679
match deref_kind ( self . tcx , base_cmt. ty ) {
675
680
deref_ptr( ptr) => {
676
681
// for unique ptrs, we inherit mutability from the
677
682
// owning reference.
678
683
let m = match ptr {
679
- uniq_ptr( * ) => {
680
- self . inherited_mutability ( base_cmt. mutbl , mt . mutbl )
684
+ uniq_ptr => {
685
+ base_cmt. mutbl . inherit ( )
681
686
}
682
- gc_ptr( * ) | region_ptr( _ , _) | unsafe_ptr => {
683
- MutabilityCategory :: from_mutbl ( mt . mutbl )
687
+ gc_ptr( m ) | region_ptr( m , _) | unsafe_ptr( m ) => {
688
+ MutabilityCategory :: from_mutbl ( m )
684
689
}
685
690
} ;
686
691
@@ -689,18 +694,18 @@ impl mem_categorization_ctxt {
689
694
span : node. span ( ) ,
690
695
cat : cat_deref ( base_cmt, deref_cnt, ptr) ,
691
696
mutbl : m,
692
- ty : mt . ty
697
+ ty : deref_ty
693
698
}
694
699
}
695
700
696
701
deref_interior( interior) => {
697
- let m = self . inherited_mutability ( base_cmt. mutbl , mt . mutbl ) ;
702
+ let m = base_cmt. mutbl . inherit ( ) ;
698
703
@cmt_ {
699
704
id : node. id ( ) ,
700
705
span : node. span ( ) ,
701
706
cat : cat_interior ( base_cmt, interior) ,
702
707
mutbl : m,
703
- ty : mt . ty
708
+ ty : deref_ty
704
709
}
705
710
}
706
711
}
@@ -742,8 +747,8 @@ impl mem_categorization_ctxt {
742
747
//! - `derefs`: the deref number to be used for
743
748
//! the implicit index deref, if any (see above)
744
749
745
- let mt = match ty:: index ( base_cmt. ty ) {
746
- Some ( mt) => mt,
750
+ let element_ty = match ty:: index ( base_cmt. ty ) {
751
+ Some ( ref mt) => mt. ty ,
747
752
None => {
748
753
self . tcx . sess . span_bug (
749
754
elt. span ( ) ,
@@ -757,11 +762,11 @@ impl mem_categorization_ctxt {
757
762
// for unique ptrs, we inherit mutability from the
758
763
// owning reference.
759
764
let m = match ptr {
760
- uniq_ptr( * ) => {
761
- self . inherited_mutability ( base_cmt. mutbl , mt . mutbl )
765
+ uniq_ptr => {
766
+ base_cmt. mutbl . inherit ( )
762
767
}
763
- gc_ptr( _ ) | region_ptr( _ , _) | unsafe_ptr => {
764
- MutabilityCategory :: from_mutbl ( mt . mutbl )
768
+ gc_ptr( m ) | region_ptr( m , _) | unsafe_ptr( m ) => {
769
+ MutabilityCategory :: from_mutbl ( m )
765
770
}
766
771
} ;
767
772
@@ -771,31 +776,31 @@ impl mem_categorization_ctxt {
771
776
span : elt. span ( ) ,
772
777
cat : cat_deref ( base_cmt, derefs, ptr) ,
773
778
mutbl : m,
774
- ty : mt . ty
779
+ ty : element_ty
775
780
} ;
776
781
777
- interior ( elt, deref_cmt, base_cmt. ty , m, mt )
782
+ interior ( elt, deref_cmt, base_cmt. ty , m, element_ty )
778
783
}
779
784
780
785
deref_interior( _) => {
781
786
// fixed-length vectors have no deref
782
- let m = self . inherited_mutability ( base_cmt. mutbl , mt . mutbl ) ;
783
- interior ( elt, base_cmt, base_cmt. ty , m, mt )
787
+ let m = base_cmt. mutbl . inherit ( ) ;
788
+ interior ( elt, base_cmt, base_cmt. ty , m, element_ty )
784
789
}
785
790
} ;
786
791
787
792
fn interior < N : ast_node > ( elt : N ,
788
793
of_cmt : cmt ,
789
794
vec_ty : ty:: t ,
790
795
mutbl : MutabilityCategory ,
791
- mt : ty:: mt ) -> cmt
796
+ element_ty : ty:: t ) -> cmt
792
797
{
793
798
@cmt_ {
794
799
id : elt. id ( ) ,
795
800
span : elt. span ( ) ,
796
801
cat : cat_interior ( of_cmt, InteriorElement ( element_kind ( vec_ty) ) ) ,
797
802
mutbl : mutbl,
798
- ty : mt . ty
803
+ ty : element_ty
799
804
}
800
805
}
801
806
}
@@ -1130,7 +1135,7 @@ impl cmt_ {
1130
1135
cat_stack_upvar( b) |
1131
1136
cat_discr( b, _) |
1132
1137
cat_interior( b, _) |
1133
- cat_deref( b, _, uniq_ptr( * ) ) => {
1138
+ cat_deref( b, _, uniq_ptr) => {
1134
1139
b. guarantor ( )
1135
1140
}
1136
1141
}
@@ -1177,7 +1182,7 @@ impl cmt_ {
1177
1182
1178
1183
cat_downcast( b) |
1179
1184
cat_stack_upvar( b) |
1180
- cat_deref( b, _, uniq_ptr( * ) ) |
1185
+ cat_deref( b, _, uniq_ptr) |
1181
1186
cat_interior( b, _) |
1182
1187
cat_discr( b, _) => {
1183
1188
b. freely_aliasable ( )
@@ -1230,10 +1235,10 @@ impl Repr for categorization {
1230
1235
1231
1236
pub fn ptr_sigil ( ptr : ptr_kind ) -> ~str {
1232
1237
match ptr {
1233
- uniq_ptr( _ ) => ~"~",
1238
+ uniq_ptr => ~"~",
1234
1239
gc_ptr ( _) => ~"@",
1235
1240
region_ptr( _, _) => ~"& ",
1236
- unsafe_ptr => ~" * "
1241
+ unsafe_ptr(_) => ~" * "
1237
1242
}
1238
1243
}
1239
1244
0 commit comments