Open
Description
When a trait is used as a bounds to a generic inherent implementation, and that inherent implementation defines a const function, methods from that bounding trait are not being handled as const inside that definition.
I tried this code:
#![feature(const_trait_impl)]
#[const_trait]
trait Foo {
fn bar(&self) -> u16;
}
struct Baz<F: Foo>(F, u16);
impl<F: Foo> Baz<F> {
const fn bat(f: F) -> u16 { f.bar() }
}
I expected to see this happen: The code would compile and use the const bar() method implemented on F.
Instead, this happened: The compiler yields the error:
error[E0277]: the trait bound `F: ~const Foo` is not satisfied
--> file.rs:11:30
|
11 | const fn bat(f: F) -> u16 { f.bar() }
| ^^^^^^^
Meta
This was tested on rustc 1.81.0-nightly (6b0f4b5 2024-06-24).