@@ -11,6 +11,7 @@ import std::list::{list, cons, nil};
11
11
import result :: { result, ok, err, extensions} ;
12
12
import syntax:: print:: pprust;
13
13
import util:: common:: indenter;
14
+ import ast_util:: op_expr_callee_id;
14
15
15
16
export check_crate, root_map, mutbl_map;
16
17
@@ -279,7 +280,7 @@ impl methods for gather_loan_ctxt {
279
280
_ {
280
281
self. bccx . span_err (
281
282
cmt. span ,
282
- #fmt[ "Cannot guarantee the stability \
283
+ #fmt[ "cannot guarantee the stability \
283
284
of this expression for the entirety of \
284
285
its lifetime, %s",
285
286
region_to_str ( self . tcx ( ) , scope_r) ] ) ;
@@ -927,21 +928,30 @@ impl categorize_methods for borrowck_ctxt {
927
928
}
928
929
}
929
930
930
- fn cat_expr( expr: @ast:: expr) -> cmt {
931
- let tcx = self . tcx ;
932
- let expr_ty = tcx. ty ( expr) ;
931
+ fn cat_method_ref( expr: @ast:: expr, expr_ty: ty:: t) -> cmt {
932
+ @{ id : expr. id , span : expr. span ,
933
+ cat : cat_special ( sk_method) , lp : none,
934
+ mutbl : m_imm, ty : expr_ty}
935
+ }
933
936
937
+ fn cat_rvalue ( expr : @ast:: expr , expr_ty : ty:: t ) -> cmt {
938
+ @{ id: expr. id , span: expr. span ,
939
+ cat: cat_rvalue, lp: none,
940
+ mutbl: m_imm, ty: expr_ty}
941
+ }
942
+
943
+ fn cat_expr ( expr : @ast:: expr ) -> cmt {
934
944
#debug[ "cat_expr: id=%d expr=%s" ,
935
945
expr. id , pprust:: expr_to_str ( expr) ] ;
936
946
937
- if self . method_map . contains_key ( expr. id ) {
938
- ret @{ id : expr. id , span : expr. span ,
939
- cat : cat_special ( sk_method) , lp : none,
940
- mutbl : m_imm, ty : expr_ty} ;
941
- }
942
-
947
+ let tcx = self . tcx ;
948
+ let expr_ty = tcx. ty ( expr) ;
943
949
alt expr. node {
944
950
ast:: expr_unary ( ast:: deref, e_base) {
951
+ if self . method_map . contains_key ( expr. id ) {
952
+ ret self . cat_rvalue ( expr, expr_ty) ;
953
+ }
954
+
945
955
let base_cmt = self . cat_expr ( e_base) ;
946
956
alt self. cat_deref ( expr, base_cmt, true ) {
947
957
some ( cmt) { ret cmt; }
@@ -955,11 +965,19 @@ impl categorize_methods for borrowck_ctxt {
955
965
}
956
966
957
967
ast:: expr_field ( base, f_name, _) {
968
+ if self . method_map . contains_key ( expr. id ) {
969
+ ret self . cat_method_ref ( expr, expr_ty) ;
970
+ }
971
+
958
972
let base_cmt = self . cat_autoderef ( expr, base) ;
959
973
self . cat_field ( expr, base_cmt, f_name, expr_ty)
960
974
}
961
975
962
976
ast:: expr_index ( base, _) {
977
+ if self . method_map . contains_key ( expr. id ) {
978
+ ret self . cat_rvalue ( expr, expr_ty) ;
979
+ }
980
+
963
981
self . cat_index ( expr, base)
964
982
}
965
983
@@ -980,9 +998,7 @@ impl categorize_methods for borrowck_ctxt {
980
998
ast:: expr_block ( * ) | ast:: expr_loop ( * ) | ast:: expr_alt ( * ) |
981
999
ast:: expr_lit ( * ) | ast:: expr_break | ast:: expr_mac ( * ) |
982
1000
ast:: expr_cont | ast:: expr_rec ( * ) {
983
- @{ id: expr. id , span: expr. span ,
984
- cat: cat_rvalue, lp: none,
985
- mutbl: m_imm, ty: expr_ty}
1001
+ ret self . cat_rvalue ( expr, expr_ty) ;
986
1002
}
987
1003
}
988
1004
}
0 commit comments