diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 49ea2181b075a..db783f5d5f605 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -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(_) => {