1
Fork 0
rust/compiler/rustc_parse/src
Noratrieb 8a02724b9d Fix const items not being allowed to be called r#move or r#static
Because of an ambiguity with const closures, the parser needs to ensure
that for a const item, the `const` keyword isn't followed by a `move` or
`static` keyword, as that would indicate a const closure:

```rust
fn main() {
  const move // ...
}
```

This check did not take raw identifiers into account, therefore being
unable to distinguish between `const move` and `const r#move`. The
latter is obviously not a const closure, so it should be allowed as a
const item.

This fixes the check in the parser to only treat `const ...` as a const
closure if it's followed by the *proper keyword*, and not a raw
identifier.

Additionally, this adds a large test that tests for all raw identifiers in
all kinds of positions, including `const`, to prevent issues like this
one from occurring again.
2025-02-16 18:21:40 +01:00
..
lexer replaces few consts with statics to reduce readonly section 2025-01-28 17:38:22 +03:00
parser Fix const items not being allowed to be called r#move or r#static 2025-02-16 18:21:40 +01:00
errors.rs Try to recover from path sep error in parser 2025-02-15 07:44:20 +08:00
lib.rs tree-wide: parallel: Fully removed all Lrc, replaced with Arc 2025-02-03 13:25:57 +03:00
validate_attr.rs Properly record metavar spans for other expansions other than TT 2024-12-21 20:37:27 +00:00