gccrs: Prevent crash on malformed 'self' segment during import finalization
gccrs now stops processing on malformed 'self' segments to avoid compiler crashes.
When a ‘self’ segment is encountered in a malformed state during import finalization, gccrs should not continue processing. Continuing could lead to a crash due to an invalid node ID retrieved. This commit modifies the Early::visit function to return early upon detecting such an error, fixing a potential crash.
In Details
This commit addresses Rust-GCC/gccrs#4735 by modifying Early::visit in resolve/rust-early-name-resolver-2.0.cc. If a 'self' segment is detected as malformed during the import finalization stage, the function now returns immediately rather than attempting to proceed. This prevents the retrieval of a potentially invalid node ID that could later crash the compiler.
- gccrs
- The GCC frontend for the Rust programming language. It translates Rust code into GCC's internal representation (GIMPLE) for optimization and code generation.
- Import Finalization
- A phase in the Rust compilation process (and likely in
gccrs) where imported items are fully processed and integrated into the compiler's internal structures. - Self Segment
- In the context of Rust compilation and potentially
gccrs, a 'self' segment might refer to a part of the internal representation related to theselfkeyword or type, particularly in the context of imports or module structures. - Node ID
- An identifier for a node within the compiler's internal data structures, such as an Abstract Syntax Tree (AST) or High-Level Intermediate Representation (HIR).