@@ -295,23 +295,29 @@ pub trait Typer<'tcx> : ty::ClosureTyper<'tcx> {
295
295
296
296
impl MutabilityCategory {
297
297
pub fn from_mutbl ( m : ast:: Mutability ) -> MutabilityCategory {
298
- match m {
298
+ let ret = match m {
299
299
MutImmutable => McImmutable ,
300
300
MutMutable => McDeclared
301
- }
301
+ } ;
302
+ debug ! ( "MutabilityCategory::{}({:?}) => {:?}" ,
303
+ "from_mutbl" , m, ret) ;
304
+ ret
302
305
}
303
306
304
307
pub fn from_borrow_kind ( borrow_kind : ty:: BorrowKind ) -> MutabilityCategory {
305
- match borrow_kind {
308
+ let ret = match borrow_kind {
306
309
ty:: ImmBorrow => McImmutable ,
307
310
ty:: UniqueImmBorrow => McImmutable ,
308
311
ty:: MutBorrow => McDeclared ,
309
- }
312
+ } ;
313
+ debug ! ( "MutabilityCategory::{}({:?}) => {:?}" ,
314
+ "from_borrow_kind" , borrow_kind, ret) ;
315
+ ret
310
316
}
311
317
312
318
pub fn from_pointer_kind ( base_mutbl : MutabilityCategory ,
313
319
ptr : PointerKind ) -> MutabilityCategory {
314
- match ptr {
320
+ let ret = match ptr {
315
321
Unique => {
316
322
base_mutbl. inherit ( )
317
323
}
@@ -321,11 +327,14 @@ impl MutabilityCategory {
321
327
UnsafePtr ( m) => {
322
328
MutabilityCategory :: from_mutbl ( m)
323
329
}
324
- }
330
+ } ;
331
+ debug ! ( "MutabilityCategory::{}({:?}, {:?}) => {:?}" ,
332
+ "from_pointer_kind" , base_mutbl, ptr, ret) ;
333
+ ret
325
334
}
326
335
327
336
fn from_local ( tcx : & ty:: ctxt , id : ast:: NodeId ) -> MutabilityCategory {
328
- match tcx. map . get ( id) {
337
+ let ret = match tcx. map . get ( id) {
329
338
ast_map:: NodeLocal ( p) | ast_map:: NodeArg ( p) => match p. node {
330
339
ast:: PatIdent ( bind_mode, _, _) => {
331
340
if bind_mode == ast:: BindByValue ( ast:: MutMutable ) {
@@ -337,30 +346,39 @@ impl MutabilityCategory {
337
346
_ => tcx. sess . span_bug ( p. span , "expected identifier pattern" )
338
347
} ,
339
348
_ => tcx. sess . span_bug ( tcx. map . span ( id) , "expected identifier pattern" )
340
- }
349
+ } ;
350
+ debug ! ( "MutabilityCategory::{}(tcx, id={:?}) => {:?}" ,
351
+ "from_local" , id, ret) ;
352
+ ret
341
353
}
342
354
343
355
pub fn inherit ( & self ) -> MutabilityCategory {
344
- match * self {
356
+ let ret = match * self {
345
357
McImmutable => McImmutable ,
346
358
McDeclared => McInherited ,
347
359
McInherited => McInherited ,
348
- }
360
+ } ;
361
+ debug ! ( "{:?}.inherit() => {:?}" , self , ret) ;
362
+ ret
349
363
}
350
364
351
365
pub fn is_mutable ( & self ) -> bool {
352
- match * self {
366
+ let ret = match * self {
353
367
McImmutable => false ,
354
368
McInherited => true ,
355
369
McDeclared => true ,
356
- }
370
+ } ;
371
+ debug ! ( "{:?}.is_mutable() => {:?}" , self , ret) ;
372
+ ret
357
373
}
358
374
359
375
pub fn is_immutable ( & self ) -> bool {
360
- match * self {
376
+ let ret = match * self {
361
377
McImmutable => true ,
362
378
McDeclared | McInherited => false
363
- }
379
+ } ;
380
+ debug ! ( "{:?}.is_immutable() => {:?}" , self , ret) ;
381
+ ret
364
382
}
365
383
366
384
pub fn to_user_str ( & self ) -> & ' static str {
@@ -733,7 +751,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
733
751
}
734
752
} ;
735
753
736
- Ok ( Rc :: new ( cmt_result) )
754
+ let ret = Rc :: new ( cmt_result) ;
755
+ debug ! ( "cat_upvar ret={}" , ret. repr( self . tcx( ) ) ) ;
756
+ Ok ( ret)
737
757
}
738
758
739
759
fn env_deref ( & self ,
@@ -794,14 +814,18 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
794
814
McDeclared | McInherited => { }
795
815
}
796
816
797
- cmt_ {
817
+ let ret = cmt_ {
798
818
id : id,
799
819
span : span,
800
820
cat : cat_deref ( Rc :: new ( cmt_result) , 0 , env_ptr) ,
801
821
mutbl : deref_mutbl,
802
822
ty : var_ty,
803
823
note : NoteClosureEnv ( upvar_id)
804
- }
824
+ } ;
825
+
826
+ debug ! ( "env_deref ret {}" , ret. repr( self . tcx( ) ) ) ;
827
+
828
+ ret
805
829
}
806
830
807
831
pub fn cat_rvalue_node ( & self ,
@@ -831,22 +855,26 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
831
855
}
832
856
}
833
857
} ;
834
- self . cat_rvalue ( id, span, re, expr_ty)
858
+ let ret = self . cat_rvalue ( id, span, re, expr_ty) ;
859
+ debug ! ( "cat_rvalue_node ret {}" , ret. repr( self . tcx( ) ) ) ;
860
+ ret
835
861
}
836
862
837
863
pub fn cat_rvalue ( & self ,
838
864
cmt_id : ast:: NodeId ,
839
865
span : Span ,
840
866
temp_scope : ty:: Region ,
841
867
expr_ty : Ty < ' tcx > ) -> cmt < ' tcx > {
842
- Rc :: new ( cmt_ {
868
+ let ret = Rc :: new ( cmt_ {
843
869
id : cmt_id,
844
870
span : span,
845
871
cat : cat_rvalue ( temp_scope) ,
846
872
mutbl : McDeclared ,
847
873
ty : expr_ty,
848
874
note : NoteNone
849
- } )
875
+ } ) ;
876
+ debug ! ( "cat_rvalue ret {}" , ret. repr( self . tcx( ) ) ) ;
877
+ ret
850
878
}
851
879
852
880
pub fn cat_field < N : ast_node > ( & self ,
@@ -855,14 +883,16 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
855
883
f_name : ast:: Name ,
856
884
f_ty : Ty < ' tcx > )
857
885
-> cmt < ' tcx > {
858
- Rc :: new ( cmt_ {
886
+ let ret = Rc :: new ( cmt_ {
859
887
id : node. id ( ) ,
860
888
span : node. span ( ) ,
861
889
mutbl : base_cmt. mutbl . inherit ( ) ,
862
890
cat : cat_interior ( base_cmt, InteriorField ( NamedField ( f_name) ) ) ,
863
891
ty : f_ty,
864
892
note : NoteNone
865
- } )
893
+ } ) ;
894
+ debug ! ( "cat_field ret {}" , ret. repr( self . tcx( ) ) ) ;
895
+ ret
866
896
}
867
897
868
898
pub fn cat_tup_field < N : ast_node > ( & self ,
@@ -871,14 +901,16 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
871
901
f_idx : uint ,
872
902
f_ty : Ty < ' tcx > )
873
903
-> cmt < ' tcx > {
874
- Rc :: new ( cmt_ {
904
+ let ret = Rc :: new ( cmt_ {
875
905
id : node. id ( ) ,
876
906
span : node. span ( ) ,
877
907
mutbl : base_cmt. mutbl . inherit ( ) ,
878
908
cat : cat_interior ( base_cmt, InteriorField ( PositionalField ( f_idx) ) ) ,
879
909
ty : f_ty,
880
910
note : NoteNone
881
- } )
911
+ } ) ;
912
+ debug ! ( "cat_tup_field ret {}" , ret. repr( self . tcx( ) ) ) ;
913
+ ret
882
914
}
883
915
884
916
fn cat_deref < N : ast_node > ( & self ,
@@ -913,10 +945,14 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
913
945
} ;
914
946
let base_cmt_ty = base_cmt. ty ;
915
947
match ty:: deref ( base_cmt_ty, true ) {
916
- Some ( mt) => self . cat_deref_common ( node, base_cmt, deref_cnt,
948
+ Some ( mt) => {
949
+ let ret = self . cat_deref_common ( node, base_cmt, deref_cnt,
917
950
mt. ty ,
918
951
deref_context,
919
- /* implicit: */ false ) ,
952
+ /* implicit: */ false ) ;
953
+ debug ! ( "cat_deref ret {}" , ret. repr( self . tcx( ) ) ) ;
954
+ ret
955
+ }
920
956
None => {
921
957
debug ! ( "Explicit deref of non-derefable type: {}" ,
922
958
base_cmt_ty. repr( self . tcx( ) ) ) ;
@@ -954,14 +990,16 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
954
990
( base_cmt. mutbl . inherit ( ) , cat_interior ( base_cmt, interior) )
955
991
}
956
992
} ;
957
- Ok ( Rc :: new ( cmt_ {
993
+ let ret = Rc :: new ( cmt_ {
958
994
id : node. id ( ) ,
959
995
span : node. span ( ) ,
960
996
cat : cat,
961
997
mutbl : m,
962
998
ty : deref_ty,
963
999
note : NoteNone
964
- } ) )
1000
+ } ) ;
1001
+ debug ! ( "cat_deref_common ret {}" , ret. repr( self . tcx( ) ) ) ;
1002
+ Ok ( ret)
965
1003
}
966
1004
967
1005
pub fn cat_index < N : ast_node > ( & self ,
@@ -1009,8 +1047,10 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
1009
1047
} ;
1010
1048
1011
1049
let m = base_cmt. mutbl . inherit ( ) ;
1012
- return Ok ( interior ( elt, base_cmt. clone ( ) , base_cmt. ty ,
1013
- m, context, element_ty) ) ;
1050
+ let ret = interior ( elt, base_cmt. clone ( ) , base_cmt. ty ,
1051
+ m, context, element_ty) ;
1052
+ debug ! ( "cat_index ret {}" , ret. repr( self . tcx( ) ) ) ;
1053
+ return Ok ( ret) ;
1014
1054
1015
1055
fn interior < ' tcx , N : ast_node > ( elt : & N ,
1016
1056
of_cmt : cmt < ' tcx > ,
@@ -1039,14 +1079,14 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
1039
1079
context : InteriorOffsetKind )
1040
1080
-> McResult < cmt < ' tcx > >
1041
1081
{
1042
- match try!( deref_kind ( base_cmt. ty , Some ( context) ) ) {
1082
+ let ret = match try!( deref_kind ( base_cmt. ty , Some ( context) ) ) {
1043
1083
deref_ptr( ptr) => {
1044
1084
// for unique ptrs, we inherit mutability from the
1045
1085
// owning reference.
1046
1086
let m = MutabilityCategory :: from_pointer_kind ( base_cmt. mutbl , ptr) ;
1047
1087
1048
1088
// the deref is explicit in the resulting cmt
1049
- Ok ( Rc :: new ( cmt_ {
1089
+ Rc :: new ( cmt_ {
1050
1090
id : elt. id ( ) ,
1051
1091
span : elt. span ( ) ,
1052
1092
cat : cat_deref ( base_cmt. clone ( ) , 0 , ptr) ,
@@ -1056,13 +1096,15 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
1056
1096
None => self . tcx ( ) . sess . bug ( "Found non-derefable type" )
1057
1097
} ,
1058
1098
note : NoteNone
1059
- } ) )
1099
+ } )
1060
1100
}
1061
1101
1062
1102
deref_interior( _) => {
1063
- Ok ( base_cmt)
1103
+ base_cmt
1064
1104
}
1065
- }
1105
+ } ;
1106
+ debug ! ( "deref_vec ret {}" , ret. repr( self . tcx( ) ) ) ;
1107
+ Ok ( ret)
1066
1108
}
1067
1109
1068
1110
/// Given a pattern P like: `[_, ..Q, _]`, where `vec_cmt` is the cmt for `P`, `slice_pat` is
@@ -1112,14 +1154,16 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
1112
1154
interior_ty : Ty < ' tcx > ,
1113
1155
interior : InteriorKind )
1114
1156
-> cmt < ' tcx > {
1115
- Rc :: new ( cmt_ {
1157
+ let ret = Rc :: new ( cmt_ {
1116
1158
id : node. id ( ) ,
1117
1159
span : node. span ( ) ,
1118
1160
mutbl : base_cmt. mutbl . inherit ( ) ,
1119
1161
cat : cat_interior ( base_cmt, interior) ,
1120
1162
ty : interior_ty,
1121
1163
note : NoteNone
1122
- } )
1164
+ } ) ;
1165
+ debug ! ( "cat_imm_interior ret={}" , ret. repr( self . tcx( ) ) ) ;
1166
+ ret
1123
1167
}
1124
1168
1125
1169
pub fn cat_downcast < N : ast_node > ( & self ,
@@ -1128,14 +1172,16 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
1128
1172
downcast_ty : Ty < ' tcx > ,
1129
1173
variant_did : ast:: DefId )
1130
1174
-> cmt < ' tcx > {
1131
- Rc :: new ( cmt_ {
1175
+ let ret = Rc :: new ( cmt_ {
1132
1176
id : node. id ( ) ,
1133
1177
span : node. span ( ) ,
1134
1178
mutbl : base_cmt. mutbl . inherit ( ) ,
1135
1179
cat : cat_downcast ( base_cmt, variant_did) ,
1136
1180
ty : downcast_ty,
1137
1181
note : NoteNone
1138
- } )
1182
+ } ) ;
1183
+ debug ! ( "cat_downcast ret={}" , ret. repr( self . tcx( ) ) ) ;
1184
+ ret
1139
1185
}
1140
1186
1141
1187
pub fn cat_pattern < F > ( & self , cmt : cmt < ' tcx > , pat : & ast:: Pat , mut op : F ) -> McResult < ( ) >
0 commit comments