about summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-17 06:37:39 +0100
committerGitHub <noreply@github.com>2025-02-17 06:37:39 +0100
commitf0710999a969d6810234066d58e40bfd7c232c7b (patch)
tree435096c3bce1ea5e5d7cc7c35c95c2d1cd3a2a49 /compiler/rustc_span/src/lib.rs
parent86f3d525e0d16decc3ea82ac226462effcbd87b4 (diff)
parent8a02724b9d0bf3a9e449a04c2d7efaa8a0521e1b (diff)
downloadrust-f0710999a969d6810234066d58e40bfd7c232c7b.tar.gz
rust-f0710999a969d6810234066d58e40bfd7c232c7b.zip
Rollup merge of #137140 - Noratrieb:const-move, r=jieyouxu,compiler-errors
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.

fixes #137128
Diffstat (limited to 'compiler/rustc_span/src/lib.rs')
0 files changed, 0 insertions, 0 deletions