Open
Description
I tried this code:
#![feature(const_trait_impl)]
#![feature(const_fn)]
use std::marker::PhantomData;
trait ConstDefault {
fn const_default() -> Self;
}
impl const ConstDefault for u8 {
fn const_default() -> Self { 0 }
}
const fn foo() -> &'static u8 {
&u8::const_default()
}
I expected to see this happen: This should pass compile if i'm not mistaken.
Instead, this happened: The const value promotion did not happen.
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant propagationArea: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.