-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undocumented: Identifier r#move
cannot be used as the name of a constant
#137128
Comments
This code used to compile fine in 1.68: https://godbolt.org/z/Mzx6PdTeM, but became a parse error in 1.69. I can't find anything in the release notes about this either. bisection gives: Regression in nightly-2023-02-06 fetching https://static.rust-lang.org/dist/2023-02-05/channel-rust-nightly-git-commit-hash.txt |
The bisection above does not seem to be correct 🤔 This happens because when parsing items, for some reason it checks that it's not a parsing a const closure, and const closures may be rust/compiler/rustc_parse/src/parser/mod.rs Line 757 in 23032f3
|
…ompiler-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 rust-lang#137128
Rollup merge of rust-lang#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 rust-lang#137128
Location
https://doc.rust-lang.org/reference/items/constant-items.html
Summary
This may cause problem in generated bindings for APIs in other languages.
https://developer.android.com/reference/android/R.transition.html#move
The text was updated successfully, but these errors were encountered: