Closed
Description
The following code compiles successfully while it should lead to an error due to the presence of the contextual keyword default
on the free constant item:
default const K: () = ();
fn main() {}
The AST validation code was incorrectly implemented and only rejects default
on free const items that don't have a body:
default const K: ();
stderr
error: `default` is only allowed on items in trait impls
--> src/lib.rs:1:1
|
1 | default const K: ();
| -------^^^^^^^^^^^^^
| |
| `default` because of this
error: free constant item without body
--> src/lib.rs:1:1
|
1 | default const K: ();
| ^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the constant: `= <expr>;`