Closed
Description
I tried this code:
#![feature(const_trait_impl)]
#[const_trait]
pub trait Aaa {
fn x() -> u8;
}
struct Impl;
impl const Aaa for Impl {
fn x() -> u8 { 0 }
}
pub const fn y() -> u8 { Impl::x() }
I expected to see this happen: it compiles without an error.
Instead, this happened:
error[E0015]: cannot call non-const fn `<Impl as Aaa>::x` in constant functions
--> src/lib.rs:14:26
|
14 | pub const fn y() -> u8 { Impl::x() }
| ^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
rustc --version --verbose
:
rustc 1.73.0-nightly (f88a8b71c 2023-08-08)
binary: rustc
commit-hash: f88a8b71cebb730cbd5058c45ebcae1d4d9be377
commit-date: 2023-08-08
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0