@@ -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
@@ -301,7 +302,7 @@ impl methods for gather_loan_ctxt {
301
302
_ {
302
303
self . bccx. span_err(
303
304
cmt. span,
304
- #fmt[ "Cannot guarantee the stability \
305
+ #fmt[ "cannot guarantee the stability \
305
306
of this expression for the entirety of \
306
307
its lifetime, %s",
307
308
region_to_str( self . tcx( ) , scope_r) ] ) ;
@@ -989,21 +990,30 @@ impl categorize_methods for borrowck_ctxt {
989
990
}
990
991
}
991
992
992
- fn cat_expr( expr: @ast:: expr) -> cmt {
993
- let tcx = self . tcx;
994
- let expr_ty = tcx. ty( expr) ;
993
+ fn cat_method_ref( expr: @ast:: expr, expr_ty: ty:: t) -> cmt {
994
+ @{ id: expr. id, span: expr. span,
995
+ cat: cat_special( sk_method) , lp: none,
996
+ mutbl: m_imm, ty: expr_ty}
997
+ }
995
998
999
+ fn cat_rvalue( expr: @ast:: expr, expr_ty: ty:: t) -> cmt {
1000
+ @{ id: expr. id, span : expr. span,
1001
+ cat : cat_rvalue, lp : none,
1002
+ mutbl : m_imm, ty : expr_ty}
1003
+ }
1004
+
1005
+ fn cat_expr( expr: @ast:: expr) -> cmt {
996
1006
#debug[ "cat_expr: id=%d expr=%s",
997
1007
expr. id, pprust : : expr_to_str( expr) ] ;
998
1008
999
- if self . method_map. contains_key( expr. id) {
1000
- ret @{ id : expr. id, span : expr. span,
1001
- cat : cat_special( sk_method) , lp : none,
1002
- mutbl : m_imm, ty : expr_ty} ;
1003
- }
1004
-
1009
+ let tcx = self . tcx;
1010
+ let expr_ty = tcx. ty( expr) ;
1005
1011
alt expr. node {
1006
1012
ast : : expr_unary( ast:: deref, e_base) {
1013
+ if self . method_map. contains_key( expr. id) {
1014
+ ret self. cat_rvalue( expr, expr_ty) ;
1015
+ }
1016
+
1007
1017
let base_cmt = self . cat_expr( e_base) ;
1008
1018
alt self. cat_deref( expr, base_cmt, 0 u, true ) {
1009
1019
some( cmt) { ret cmt; }
@@ -1017,11 +1027,19 @@ impl categorize_methods for borrowck_ctxt {
1017
1027
}
1018
1028
1019
1029
ast:: expr_field( base, f_name, _) {
1030
+ if self . method_map. contains_key( expr. id) {
1031
+ ret self . cat_method_ref( expr, expr_ty) ;
1032
+ }
1033
+
1020
1034
let base_cmt = self . cat_autoderef( base) ;
1021
1035
self . cat_field( expr, base_cmt, f_name)
1022
1036
}
1023
1037
1024
1038
ast:: expr_index( base, _) {
1039
+ if self . method_map. contains_key( expr. id) {
1040
+ ret self . cat_rvalue( expr, expr_ty) ;
1041
+ }
1042
+
1025
1043
self . cat_index( expr, base)
1026
1044
}
1027
1045
@@ -1042,9 +1060,7 @@ impl categorize_methods for borrowck_ctxt {
1042
1060
ast:: expr_block( * ) | ast:: expr_loop( * ) | ast:: expr_alt( * ) |
1043
1061
ast:: expr_lit( * ) | ast:: expr_break | ast:: expr_mac( * ) |
1044
1062
ast:: expr_cont | ast:: expr_rec( * ) {
1045
- @{ id: expr. id, span: expr. span,
1046
- cat: cat_rvalue, lp: none,
1047
- mutbl: m_imm, ty: expr_ty}
1063
+ ret self. cat_rvalue( expr, expr_ty) ;
1048
1064
}
1049
1065
}
1050
1066
}
0 commit comments