Closed
Description
Proposing to extract this from #57349.
The following examples shouldn't error:
const fn get_some_fn() -> fn(&mut String) {
String::clear
}
const fn use_const_fn(_f: fn(&mut String)) {
()
}
const fn some_const_fn() {
let _f: fn(&mut String) = String::clear;
}
// mutable references are not allowed in constant functions x3
While this has been considered part of #57349 for a while, it's also been acknowledged as a bug and suggested by @RalfJung to address separately ahead of stabilizing const_mut_refs
. Indeed it's surprising for users that this would count as handling a mutable reference in const contexts.