Files
rust/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.rs
Oli Scherer 8e1c34f5cc Check closure's constness validity in the constness query
instead of during ast lowering, where it's not easily possible to obtain all the right information in time
2026-04-27 07:44:19 +02:00

14 lines
317 B
Rust

#![feature(const_closures)]
// Regression test for https://github.com/rust-lang/rust/issues/153891
trait Tr {
const fn test() {
//~^ ERROR functions in traits cannot be declared const
(const || {})()
//~^ ERROR cannot use `const` closures outside of const contexts
}
}
fn main() {}