Files
rust/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
293 B
Rust
Raw Normal View History

2025-08-11 19:36:20 -04:00
#![feature(const_trait_impl, const_convert)]
2021-12-06 20:46:05 +08:00
2025-07-11 08:17:58 +00:00
//@ check-pass
2021-12-06 20:46:05 +08:00
2022-08-28 06:27:31 +00:00
#[const_trait]
2021-12-06 20:46:05 +08:00
trait Convert<T> {
fn to(self) -> T;
}
impl<A, B> const Convert<B> for A where B: [const] From<A> {
2021-12-06 20:46:05 +08:00
fn to(self) -> B {
B::from(self)
}
}
const FOO: fn() -> String = || "foo".to();
2021-12-05 19:03:01 +08:00
fn main() {}