Given the following code (playground):
#![feature(const_mut_refs)]
#![feature(const_trait_impl)]
const fn call_twice<F>(mut f: F)
where
F: ~const FnMut() -> (),
{
f();
f();
}
fn main() {
let mut a = 10;
call_twice(|| { a -= 1; });
assert_eq!(a, 8);
}
The current output is:
error[E0493]: destructor of `F` cannot be evaluated at compile-time
--> src/main.rs:4:24
|
4 | const fn call_twice<F>(mut f: F)
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
10 | }
| - value is dropped here
Ideally the output should suggest a where-clause fix:
help: consider restricting `F` to be destructible in const contexts:
| where
6| F: ~const FnMut() -> () + ~const std::marker::Destruct,
| +++++++++++++++++++++++++++++++
Given the following code (playground):
The current output is:
Ideally the output should suggest a
where-clause fix: