@@ -936,37 +936,55 @@ fn constrain_call<'a, I: Iterator<Item=&'a ast::Expr>>(rcx: &mut Rcx,
936
936
fn constrain_autoderefs < ' a , ' tcx > ( rcx : & mut Rcx < ' a , ' tcx > ,
937
937
deref_expr : & ast:: Expr ,
938
938
derefs : uint ,
939
- mut derefd_ty : Ty < ' tcx > ) {
939
+ mut derefd_ty : Ty < ' tcx > )
940
+ {
941
+ debug ! ( "constrain_autoderefs(deref_expr={}, derefs={}, derefd_ty={})" ,
942
+ deref_expr. repr( rcx. tcx( ) ) ,
943
+ derefs,
944
+ derefd_ty. repr( rcx. tcx( ) ) ) ;
945
+
940
946
let r_deref_expr = ty:: ReScope ( CodeExtent :: from_node_id ( deref_expr. id ) ) ;
941
947
for i in range ( 0 u, derefs) {
942
- debug ! ( "constrain_autoderefs(deref_expr=?, derefd_ty={}, derefs={}/{}" ,
943
- rcx. fcx. infcx( ) . ty_to_string( derefd_ty) ,
944
- i, derefs) ;
945
-
946
948
let method_call = MethodCall :: autoderef ( deref_expr. id , i) ;
949
+ debug ! ( "constrain_autoderefs: method_call={:?} (of {:?} total)" , method_call, derefs) ;
950
+
947
951
derefd_ty = match rcx. fcx . inh . method_map . borrow ( ) . get ( & method_call) {
948
952
Some ( method) => {
953
+ debug ! ( "constrain_autoderefs: #{} is overloaded, method={}" ,
954
+ i, method. repr( rcx. tcx( ) ) ) ;
955
+
949
956
// Treat overloaded autoderefs as if an AutoRef adjustment
950
957
// was applied on the base type, as that is always the case.
951
958
let fn_sig = ty:: ty_fn_sig ( method. ty ) ;
952
- let self_ty = fn_sig. 0 . inputs [ 0 ] ;
959
+ let fn_sig = // late-bound regions should have been instantiated
960
+ ty:: assert_no_late_bound_regions ( rcx. tcx ( ) , fn_sig) ;
961
+ let self_ty = fn_sig. inputs [ 0 ] ;
953
962
let ( m, r) = match self_ty. sty {
954
963
ty:: ty_rptr( r, ref m) => ( m. mutbl , r) ,
955
- _ => rcx. tcx ( ) . sess . span_bug ( deref_expr. span ,
964
+ _ => {
965
+ rcx. tcx ( ) . sess . span_bug (
966
+ deref_expr. span ,
956
967
& format ! ( "bad overloaded deref type {}" ,
957
- method. ty. repr( rcx. tcx( ) ) ) [ ] )
968
+ method. ty. repr( rcx. tcx( ) ) ) [ ] )
969
+ }
958
970
} ;
971
+
972
+ debug ! ( "constrain_autoderefs: receiver r={:?} m={:?}" ,
973
+ r. repr( rcx. tcx( ) ) , m) ;
974
+
959
975
{
960
976
let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
961
977
let self_cmt = ignore_err ! ( mc. cat_expr_autoderefd( deref_expr, i) ) ;
978
+ debug ! ( "constrain_autoderefs: self_cmt={:?}" ,
979
+ self_cmt. repr( rcx. tcx( ) ) ) ;
962
980
link_region ( rcx, deref_expr. span , * r,
963
981
ty:: BorrowKind :: from_mutbl ( m) , self_cmt) ;
964
982
}
965
983
966
984
// Specialized version of constrain_call.
967
985
type_must_outlive ( rcx, infer:: CallRcvr ( deref_expr. span ) ,
968
986
self_ty, r_deref_expr) ;
969
- match fn_sig. 0 . output {
987
+ match fn_sig. output {
970
988
ty:: FnConverging ( return_type) => {
971
989
type_must_outlive ( rcx, infer:: CallReturn ( deref_expr. span ) ,
972
990
return_type, r_deref_expr) ;
@@ -1185,7 +1203,7 @@ fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
1185
1203
id : ast:: NodeId ,
1186
1204
mutbl : ast:: Mutability ,
1187
1205
cmt_borrowed : mc:: cmt < ' tcx > ) {
1188
- debug ! ( "link_region_from_node_type(id={}, mutbl={}, cmt_borrowed={})" ,
1206
+ debug ! ( "link_region_from_node_type(id={:? }, mutbl={:? }, cmt_borrowed={})" ,
1189
1207
id, mutbl, cmt_borrowed. repr( rcx. tcx( ) ) ) ;
1190
1208
1191
1209
let rptr_ty = rcx. resolve_node_type ( id) ;
0 commit comments