pub struct ImportScope {
pub file_module: Option<String>,
pub qualified_modules: BTreeSet<String>,
pub bare_imports: BTreeSet<(String, String)>,
pub aliases: BTreeMap<String, (String, String)>,
}Expand description
Per-file import context threaded into resolution (M-2d, docs/modules-spec.md §2; issue #790) so a bare reference with multiple cross-module candidates binds to the module this file actually imports — “names cross module boundaries only via import” — rather than to the flat duplicate-winner.
The default (empty) scope reproduces the pre-M-2d flat behavior exactly:
the entire strict-ink and single-module world has at most one candidate
per (name, kind), so [lookup_by_name]’s fast path returns it unchanged
and this context never influences the result. It only ever disambiguates
the genuinely-new case unlocked by relaxing the #784/#793 stopgap: two
declared modules publicly defining the same name, now coexisting in the
index instead of one being suppressed.
Fields§
§file_module: Option<String>The referring file’s own declared module (None for an
undeclared stem-module / the legacy world). A candidate declared in
this same module is bare-visible without any import.
qualified_modules: BTreeSet<String>Modules this file imports qualified (IMPORT mod) — licenses
module.name access to any public export of that module.
bare_imports: BTreeSet<(String, String)>(module, name) pairs this file imports bare
(IMPORT { name } FROM mod) — name-precise, matching
modules::import_covers exactly so resolution and the E025
import-required diagnostic can never diverge. BTreeSet for
determinism. Keyed by the imported item’s own (source-module) name
regardless of any local alias — an aliased import still covers its
source name for cross-module licensing purposes (§2: the file did
import it), it just isn’t the name resolution binds bare (see
aliases).
aliases: BTreeMap<String, (String, String)>Local alias → (module, source_name) for every bare import item that
named one (IMPORT { name AS alias } FROM mod / use mod::name as alias;, issue #1590). index.by_name is keyed by definitions’ own
spellings only, so a plain [lookup_by_name] lookup can never find an
alias — this table is the indirection [lookup_by_name] falls back to
once the direct-name lookup comes up empty. Additive, not
shadowing: aliasing doesn’t revoke the source name’s own bare
visibility (still governed by bare_imports/classify exactly as
before) — it only adds a second local spelling for the same import.
See the doc comment on [lookup_by_name] for the alias-vs-original
licensing ruling. BTreeMap for determinism.
Implementations§
Trait Implementations§
Source§impl Clone for ImportScope
impl Clone for ImportScope
Source§fn clone(&self) -> ImportScope
fn clone(&self) -> ImportScope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImportScope
impl Debug for ImportScope
Source§impl Default for ImportScope
impl Default for ImportScope
Source§fn default() -> ImportScope
fn default() -> ImportScope
impl Eq for ImportScope
Source§impl PartialEq for ImportScope
impl PartialEq for ImportScope
impl StructuralPartialEq for ImportScope
Auto Trait Implementations§
impl Freeze for ImportScope
impl RefUnwindSafe for ImportScope
impl Send for ImportScope
impl Sync for ImportScope
impl Unpin for ImportScope
impl UnsafeUnpin for ImportScope
impl UnwindSafe for ImportScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.