gccrs: Fix ignored self in grouped glob imports
Resolves an issue where `self` imports were ignored in grouped glob imports in gccrs.
This patch corrects an issue in gccrs where grouped imports combining self with a glob pattern (e.g., use path::module::{self, *};) failed to import the base module itself. The fix ensures that self imports are assigned unique NodeIds, preventing them from being inadvertently dropped during the name resolution process. This resolves a bug where inner items were imported via the glob, but the module itself was not.
In Details
The Early::resolve_rebind_import function in gccrs's early name resolver previously used the parent's NodeId for self imports within grouped globs. This conflicted with the NodeId used by the glob (*), leading to the self import being ignored. This commit modifies the resolver to use the final segment's NodeId for self imports, ensuring it has a distinct identifier and is correctly resolved alongside globbed items.
- grouped import
- In Rust, a syntax for importing multiple items from a module within a single
usestatement, often using curly braces, e.g.,use std::collections::{HashMap, HashSet};. - glob import
- A Rust import that brings all public items from a module into scope using a wildcard, e.g.,
use std::collections::*;. - self import
- In Rust,
selfwithin a module path in ausestatement refers to the module itself, allowing it to be brought into scope along with other items. - NodeId
- An internal unique identifier used by the gccrs compiler to represent various entities in the Abstract Syntax Tree (AST) and other intermediate representations, such as modules, functions, and variables.
- name resolution
- The compiler phase responsible for determining which identifier (like a variable or function name) refers to which declaration in the source code, considering scope and imports.