Closed as not planned
Description
Code
I tried this code:
#![feature(const_trait_impl)]
#[const_trait]
trait Foo {
fn foo(&self) -> i32;
}
struct X;
impl const Foo for X {
fn foo(&self) -> i32 { 4 }
}
const fn call_foo<F>(x: &F) -> i32
where
F: ~const Foo,
{
x.foo()
}
Version it worked on
It compiled successfully on nightly 2023-07-31, it may succeed on later versions.
Version with regression
It failed to compile on nightly 2023-08-13 with:
error[[E0015]](https://doc.rust-lang.org/nightly/error_codes/E0015.html): cannot call non-const fn `<F as Foo>::foo` in constant functions
--> src/lib.rs:18:7
|
18 | x.foo()
| ^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants