Skip to content

Commit 04bb68a

Browse files
compiler: recomment needs_fn_once_adapter_shim
This requires digging up ffee956 and reading the comments there to understand that the callee in resolve_closure previously directly handled a function pointer value.
1 parent e43d139 commit 04bb68a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

compiler/rustc_middle/src/ty/instance.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -991,18 +991,16 @@ fn needs_fn_once_adapter_shim(
991991
Ok(false)
992992
}
993993
(ty::ClosureKind::Fn, ty::ClosureKind::FnMut) => {
994-
// The closure fn `llfn` is a `fn(&self, ...)`. We want a
995-
// `fn(&mut self, ...)`. In fact, at codegen time, these are
996-
// basically the same thing, so we can just return llfn.
994+
// The closure fn is a `fn(&self, ...)`, but we want a `fn(&mut self, ...)`.
995+
// At codegen time, these are basically the same, so we can just return the closure.
997996
Ok(false)
998997
}
999998
(ty::ClosureKind::Fn | ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => {
1000-
// The closure fn `llfn` is a `fn(&self, ...)` or `fn(&mut
1001-
// self, ...)`. We want a `fn(self, ...)`. We can produce
1002-
// this by doing something like:
999+
// The closure fn is a `fn(&self, ...)` or `fn(&mut self, ...)`, but
1000+
// we want a `fn(self, ...)`. We can produce this by doing something like:
10031001
//
1004-
// fn call_once(self, ...) { call_mut(&self, ...) }
1005-
// fn call_once(mut self, ...) { call_mut(&mut self, ...) }
1002+
// fn call_once(self, ...) { Fn::call(&self, ...) }
1003+
// fn call_once(mut self, ...) { FnMut::call_mut(&mut self, ...) }
10061004
//
10071005
// These are both the same at codegen time.
10081006
Ok(true)

0 commit comments

Comments
 (0)