GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

Name resolve extern crate independently.

Resolves extern crates separately to correctly handle crate-relative paths like `crate::`.

This commit changes gccrs to resolve extern crates independently. This is necessary because extern crates are exported with their own declarations, and references like crate:: within the current crate should point to the extern crate’s root, not the current crate’s root. Resolving them in isolation simplifies the process and avoids complications with late name resolution, which is not required for extern crates.

In Details

GCC's Rust frontend now isolates the name resolution of extern crates. A new visitor collects and loads extern crates, their contexts are merged into the main crate's context, but their internal resolution is performed independently. This addresses issues with crate:: paths in the current crate potentially resolving to the wrong crate's root, especially when an extern crate is also named crate. This separation is feasible as extern crates do not require late name resolution.

For Context
name resolution
The process of determining which identifier in source code refers to which declaration, such as a function, variable, or type.
extern crate
In Rust, a keyword used to declare that a crate (a compilation unit) is external to the current one and should be made available for use.
crate
A compilation unit in Rust, typically a library or binary, defined by a Cargo.toml manifest file.
crate-relative path
A path in Rust that starts with crate::, referring to an item within the current crate's root module.
late name resolution
A phase in Rust compilation where types and other entities are fully resolved after initial parsing and name binding, often catching errors related to function return types and complex trait bounds.
Filed Under: gccrsrustname resolutioncompiler internals