Skip to content

Call implementations of the Fn* traits on references #137252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// ^ without this hack `f` would have to be declared as mutable
//
// The simplest fix by far is to just ignore this case and deref again,
// so we wind up with `FnMut::call_mut(&mut *f, ())`.
ty::Ref(..) if autoderef.step_count() == 0 => {
return None;
// so we wind up with `FnMut::call_mut(&mut *f, ())`. This does not
// apply to structs, enums, or unions; because they should be `mut`
// if they use `call_mut()`.
ty::Ref(_, deref_ty, _) if autoderef.step_count() == 0 => {
match deref_ty.kind() {
ty::Adt(..) => {}
_ => return None,
};
}

ty::Error(_) => {
Expand Down
Loading