You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggest ~const std::marker::Destruct for type parameters when needed #103270
#![feature(const_mut_refs)]#![feature(const_trait_impl)]constfncall_twice<F>(mutf:F)whereF: ~constFnMut() -> (),{f();f();}fnmain(){letmut 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,
| +++++++++++++++++++++++++++++++
Activity
chenyukang commentedon Oct 20, 2022
@rustbot claim
Rollup merge of rust-lang#155013 - jakubadamw:issue-103270, r=oli-obk
Rollup merge of rust-lang#155013 - jakubadamw:issue-103270, r=oli-obk
Rollup merge of rust-lang#155013 - jakubadamw:issue-103270, r=oli-obk
Unrolled build for #155013
Rollup merge of #155013 - jakubadamw:issue-103270, r=oli-obk