Files
rust/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.stderr
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

19 lines
544 B
Plaintext

error[E0379]: functions in traits cannot be declared const
--> $DIR/const-closure-in-non-const-trait-method.rs:6:5
|
LL | const fn test() {
| ^^^^^-
| |
| functions in traits cannot be const
| help: remove the `const`
error: cannot use `const` closures outside of const contexts
--> $DIR/const-closure-in-non-const-trait-method.rs:8:10
|
LL | (const || {})()
| ^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0379`.