Skip to content

Commit 55d0adf

Browse files
committed
---
yaml --- r: 173054 b: refs/heads/snap-stage3 c: 9b5fb60 h: refs/heads/master v: v3
1 parent c8a9e93 commit 55d0adf

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 896cb36ecab3eaeb7f101087e030e43771eca5ca
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 92425496e525855fd772f771a35456a4b66c071f
4+
refs/heads/snap-stage3: 9b5fb6091a99dc7675c79bfc758ae2ecb3a8cc96
55
refs/heads/try: 957472483d3a2f43c0e4f7c2056280a1022af93c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc_typeck/check/regionck.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -936,37 +936,55 @@ fn constrain_call<'a, I: Iterator<Item=&'a ast::Expr>>(rcx: &mut Rcx,
936936
fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
937937
deref_expr: &ast::Expr,
938938
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+
940946
let r_deref_expr = ty::ReScope(CodeExtent::from_node_id(deref_expr.id));
941947
for i in range(0u, derefs) {
942-
debug!("constrain_autoderefs(deref_expr=?, derefd_ty={}, derefs={}/{}",
943-
rcx.fcx.infcx().ty_to_string(derefd_ty),
944-
i, derefs);
945-
946948
let method_call = MethodCall::autoderef(deref_expr.id, i);
949+
debug!("constrain_autoderefs: method_call={:?} (of {:?} total)", method_call, derefs);
950+
947951
derefd_ty = match rcx.fcx.inh.method_map.borrow().get(&method_call) {
948952
Some(method) => {
953+
debug!("constrain_autoderefs: #{} is overloaded, method={}",
954+
i, method.repr(rcx.tcx()));
955+
949956
// Treat overloaded autoderefs as if an AutoRef adjustment
950957
// was applied on the base type, as that is always the case.
951958
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];
953962
let (m, r) = match self_ty.sty {
954963
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,
956967
&format!("bad overloaded deref type {}",
957-
method.ty.repr(rcx.tcx()))[])
968+
method.ty.repr(rcx.tcx()))[])
969+
}
958970
};
971+
972+
debug!("constrain_autoderefs: receiver r={:?} m={:?}",
973+
r.repr(rcx.tcx()), m);
974+
959975
{
960976
let mc = mc::MemCategorizationContext::new(rcx.fcx);
961977
let self_cmt = ignore_err!(mc.cat_expr_autoderefd(deref_expr, i));
978+
debug!("constrain_autoderefs: self_cmt={:?}",
979+
self_cmt.repr(rcx.tcx()));
962980
link_region(rcx, deref_expr.span, *r,
963981
ty::BorrowKind::from_mutbl(m), self_cmt);
964982
}
965983

966984
// Specialized version of constrain_call.
967985
type_must_outlive(rcx, infer::CallRcvr(deref_expr.span),
968986
self_ty, r_deref_expr);
969-
match fn_sig.0.output {
987+
match fn_sig.output {
970988
ty::FnConverging(return_type) => {
971989
type_must_outlive(rcx, infer::CallReturn(deref_expr.span),
972990
return_type, r_deref_expr);
@@ -1185,7 +1203,7 @@ fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
11851203
id: ast::NodeId,
11861204
mutbl: ast::Mutability,
11871205
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={})",
11891207
id, mutbl, cmt_borrowed.repr(rcx.tcx()));
11901208

11911209
let rptr_ty = rcx.resolve_node_type(id);

0 commit comments

Comments
 (0)