- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Closed
Copy link
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.
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      x3While 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.
joseluis
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.