diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2025-07-09 20:50:17 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2025-07-09 20:53:23 -0700 |
| commit | 04bb68ac869bc4d55bcb260398470b0c5eea4a40 (patch) | |
| tree | a3a35f3356d44db6728c5a0f198cf4d0e0459bf0 /compiler/rustc_middle/src/ty/instance.rs | |
| parent | e43d139a82620a268d3828a73e12a8679339e8f8 (diff) | |
| download | rust-04bb68ac869bc4d55bcb260398470b0c5eea4a40.tar.gz rust-04bb68ac869bc4d55bcb260398470b0c5eea4a40.zip | |
compiler: recomment `needs_fn_once_adapter_shim`
This requires digging up ffee9566bbd7728e6411e6094105d6905373255d and reading the comments there to understand that the callee in resolve_closure previously directly handled a function pointer value.
Diffstat (limited to 'compiler/rustc_middle/src/ty/instance.rs')
| -rw-r--r-- | compiler/rustc_middle/src/ty/instance.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 21b7500e46f..d5767ca3786 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -991,18 +991,16 @@ fn needs_fn_once_adapter_shim( Ok(false) } (ty::ClosureKind::Fn, ty::ClosureKind::FnMut) => { - // The closure fn `llfn` is a `fn(&self, ...)`. We want a - // `fn(&mut self, ...)`. In fact, at codegen time, these are - // basically the same thing, so we can just return llfn. + // The closure fn is a `fn(&self, ...)`, but we want a `fn(&mut self, ...)`. + // At codegen time, these are basically the same, so we can just return the closure. Ok(false) } (ty::ClosureKind::Fn | ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => { - // The closure fn `llfn` is a `fn(&self, ...)` or `fn(&mut - // self, ...)`. We want a `fn(self, ...)`. We can produce - // this by doing something like: + // The closure fn is a `fn(&self, ...)` or `fn(&mut self, ...)`, but + // we want a `fn(self, ...)`. We can produce this by doing something like: // - // fn call_once(self, ...) { call_mut(&self, ...) } - // fn call_once(mut self, ...) { call_mut(&mut self, ...) } + // fn call_once(self, ...) { Fn::call(&self, ...) } + // fn call_once(mut self, ...) { FnMut::call_mut(&mut self, ...) } // // These are both the same at codegen time. Ok(true) |
