Ensure last segment resolves to expr item in gccrs path checking
GCC Rust's path resolution now correctly treats the last segment as an expression item, fixing a bug related to path parsing.
Philip Herron modified gccrs to ensure that only the last segment of a path resolves to an expression item during type checking.
This change is part of a larger fix for an issue related to path parsing and resolution.
It specifically targets the resolve_segments function in rust-hir-type-check-path.cc.
In Details
In gccrs, the TypeCheckExpr::resolve_segments function in rust-hir-type-check-path.cc has been updated. Previously, intermediate segments in a path might have been incorrectly probed as expression items. This commit enforces that only the final segment of a path is resolved as an expression item, aligning with expected behavior for path resolution in Rust. This is a step towards fixing issue 4865.
- path resolution
- The process by which the compiler determines the meaning and type of an identifier, especially when it involves modules, namespaces, or complex scopes. In Rust, paths are used to refer to items like functions, structs, and modules.
- expression item
- An item that can be evaluated to produce a value. In the context of Rust's HIR (High-level Intermediate Representation), this refers to nodes representing expressions.
- HIR (High-level Intermediate Representation)
- An abstract syntax tree (AST) like representation used within the compiler after initial parsing, but before lower-level intermediate representations. It captures more semantic information than the AST.