Closed
Description
It looks like I'm incorrectly being warned of a constant evaluation error on valid code. The code runs just fine and is not violating the constant function requirements.
Offending code:
#![feature(const_fn)]
pub struct Data<T> {
function: fn() -> T,
}
impl<T> Data<T> {
pub const fn new(function: fn() -> T) -> Data<T> {
Data {
function: function,
}
}
}
pub static DATA: Data<i32> = Data::new(|| {
413i32
});
fn main() {
print!("{:?}", (DATA.function)());
}
Incorrect error:
warning: constant evaluation error: unsupported constant expr
--> src/main.rs:15:30
|
15 | pub static DATA: Data<i32> = Data::new(|| {
| ______________________________^
16 | | 413i32
17 | | });
| |__^
|
= note: #[warn(const_err)] on by default
Example of the issue on the playground in nightly.
Ping #24111
Metadata
Metadata
Assignees
Labels
No labels