WEDNESDAY, OCTOBER 28, 2026
gccrs
Disallow `crate` keyword at the start of a global path in Rust
Rust compiler now emits an error if a global path starts with the `crate` keyword, preventing invalid syntax.
The GCC Rust frontend now correctly identifies and reports an error when the crate keyword is used at the beginning of a global path. This invalid syntax is disallowed in Rust, and the compiler ensures this rule is enforced. A new test case verifies this behavior.
In Details
The gccrs name resolution logic now explicitly checks for and rejects paths starting with ::crate. This enforces a language rule where crate is not a valid segment at the beginning of a path starting from the crate root. The change modifies rust-forever-stack.hxx and adds a new test case to cover this validation.
For Context
- global path
- In Rust, a path that starts with
::to refer to an item from the extern prelude or the current crate's root. - crate
- The compilation unit in Rust, which can be a library or a binary. It's the top-level scope for items.
- `crate` keyword
- A keyword in Rust that, when used in a path, refers to the current crate's root. Its usage at the beginning of a global path is invalid.
- extern prelude
- A set of modules and types that are implicitly imported into every Rust crate, providing common functionality.