Skip to content

Commit 71b2dd8

Browse files
committed
---
yaml --- r: 195562 b: refs/heads/master c: cdb10b8 h: refs/heads/master v: v3
1 parent ad4ab49 commit 71b2dd8

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: cead47ca53a2c6bb0f774264131dccbc0936d90b
2+
refs/heads/master: cdb10b884b3975dd897096e052f386f55cf0f4c9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b3317d68910900f135f9f38e43a7a699bc736b4a
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf

trunk/src/librustc_typeck/check/callee.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ pub fn check_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
8383
UnresolvedTypeAction::Error,
8484
LvaluePreference::NoPreference,
8585
|adj_ty, idx| {
86-
let autoderefref = ty::AutoDerefRef { autoderefs: idx, autoref: None };
87-
try_overloaded_call_step(fcx, call_expr, callee_expr,
88-
adj_ty, autoderefref)
86+
try_overloaded_call_step(fcx, call_expr, callee_expr, adj_ty, idx)
8987
});
9088

9189
match result {
@@ -119,13 +117,15 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
119117
call_expr: &'tcx ast::Expr,
120118
callee_expr: &'tcx ast::Expr,
121119
adjusted_ty: Ty<'tcx>,
122-
autoderefref: ty::AutoDerefRef<'tcx>)
120+
autoderefs: usize)
123121
-> Option<CallStep<'tcx>>
124122
{
125-
debug!("try_overloaded_call_step(call_expr={}, adjusted_ty={}, autoderefref={})",
123+
debug!("try_overloaded_call_step(call_expr={}, adjusted_ty={}, autoderefs={})",
126124
call_expr.repr(fcx.tcx()),
127125
adjusted_ty.repr(fcx.tcx()),
128-
autoderefref.repr(fcx.tcx()));
126+
autoderefs);
127+
128+
let autoderefref = ty::AutoDerefRef { autoderefs: autoderefs, autoref: None };
129129

130130
// If the callee is a bare function or a closure, then we're all set.
131131
match structurally_resolved_type(fcx, callee_expr.span, adjusted_ty).sty {
@@ -161,6 +161,18 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
161161
}
162162
}
163163

164+
// Hack: we know that there are traits implementing Fn for &F
165+
// where F:Fn and so forth. In the particular case of types
166+
// like `x: &mut FnMut()`, if there is a call `x()`, we would
167+
// normally translate to `FnMut::call_mut(&mut x, ())`, but
168+
// that winds up requiring `mut x: &mut FnMut()`. A little
169+
// over the top. The simplest fix by far is to just ignore
170+
// this case and deref again, so we wind up with
171+
// `FnMut::call_mut(&mut *x, ())`.
172+
ty::ty_rptr(..) if autoderefs == 0 => {
173+
return None;
174+
}
175+
164176
_ => {}
165177
}
166178

0 commit comments

Comments
 (0)