From 4c56758499e5528ad1624894911c9150b66d66a5 Mon Sep 17 00:00:00 2001 From: Mike Maley Date: Tue, 18 Feb 2025 21:20:18 -0500 Subject: [PATCH 1/2] Update callee.rs --- compiler/rustc_hir_typeck/src/callee.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 49ea2181b075a..6b8b1de687458 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -224,8 +224,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // // 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; + ty::Ref(_, deref_ty, _) if autoderef.step_count() == 0 => { + match deref_ty.kind() { + ty::Adt(..) => {}, + _ => {return None} + } } ty::Error(_) => { From d97eaf80abf2fc88abfe09bd54d1f5669f4d42bd Mon Sep 17 00:00:00 2001 From: Mike Maley Date: Wed, 19 Feb 2025 06:38:57 -0500 Subject: [PATCH 2/2] Update callee.rs Added comments and improved formatting. --- compiler/rustc_hir_typeck/src/callee.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 6b8b1de687458..db783f5d5f605 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -223,12 +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, ())`. + // 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::Adt(..) => {} + _ => return None, + }; } ty::Error(_) => {