Skip to content

Commit d68fc93

Browse files
committed
---
yaml --- r: 196265 b: refs/heads/tmp c: cdb10b8 h: refs/heads/master i: 196263: 6173325 v: v3
1 parent fd6a690 commit d68fc93

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
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 9854143cba679834bc4ef932858cd5303f015a0e
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: cead47ca53a2c6bb0f774264131dccbc0936d90b
35+
refs/heads/tmp: cdb10b884b3975dd897096e052f386f55cf0f4c9
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: 53a183f0274316596bf9405944d4f0468d8c93e4
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/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)