-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]``#![feature(const_trait_impl)]`F-trait_alias`#![feature(trait_alias)]``#![feature(trait_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-effectsThe effect system based scheme for const fns resolves this.The effect system based scheme for const fns resolves this.
Description
const_trait_impl cannot utilize const traits when satisfying const bounds using a trait alias trait_alias
#![feature(trait_alias)]
#![feature(const_trait_impl)]
#[const_trait]
trait Default {
fn default() -> Self;
}
#[const_trait]
trait TraitAlias = ~const Default + Sized;
#[const_trait]
trait OwnTrait: ~const Default + Sized {
const INTERESTING_CONSTANT: Self;
}
impl<T: ~const TraitAlias + Sized> const OwnTrait for T {
const INTERESTING_CONSTANT: Self = T::default();
}There is not way to specify const-ness using trait bounds. The compile error does specify adding a #[const_trait] attribute, but this is not possible for trait aliases;
rustc --version --verbose:
rustc 1.68.0-nightly (d6f99e535 2023-01-02)
binary: rustc
commit-hash: d6f99e535a301a421dfee52a7c25bb4bdf420344
commit-date: 2023-01-02
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]``#![feature(const_trait_impl)]`F-trait_alias`#![feature(trait_alias)]``#![feature(trait_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-effectsThe effect system based scheme for const fns resolves this.The effect system based scheme for const fns resolves this.