Expand description
Name resolution across the units of a module, and across the modules of a package.
Resolution produces the flat program the runtime executes and the derived
facts (export visibility, required capabilities, trait conformances)
that tooling reports.
ADR 0005 makes a module able to name another module’s exported
declarations, so resolution is a package-wide pass rather than a
per-module one: a use is checked against another module’s declarations,
the module dependency graph must be acyclic, and required capabilities are
derived from the whole package’s call graph.
§What a derived capability set promises
ADR 0015: a derived set is a lower bound. Function types carry no latent
capability set, so a call through a function value, a dyn Trait
receiver, or a generic parameter’s bound is one the call graph cannot
follow to a declaration. Rather than pretend otherwise, resolution records
why it could not — FnEntry::open_calls — and propagates that along
the same edges the capabilities travel. A function that carries no open
call has a complete set; one that does has a floor and says so, and the
runtime’s grant check remains the only thing that decides what a call may
actually do.
§Conformances
An impl Trait for Type block is checked here and then flattened: every
method it supplies, and every method the trait defaults that it does not
override, is recorded as an ordinary method of the type. Dispatch never
has to ask where a method came from, and a trait method that collides with
an inherent method of the same name is caught by the same duplicate check
that catches two inherent methods.
The conformance itself is recorded separately, because the set of a trait’s implementors is a fact the type checker needs (to check a bound) and tooling needs (to show a type’s interface).
Either party to a conformance may be imported (ADR 0006’s orphan rule names the module that declares the trait or the module that declares the type; ADR 0005 lets a third module name both), so the rule is checked against what the module declares, not against what it can see. The two rules together also make a conformance unique without a further check: for both parties’ modules to declare the same one, each would have to import the other, which is the cycle ADR 0005 forbids.
Structs§
- Alias
Entry - Conformance
- One
impl Trait for Typeblock: the fact thattype_nameconforms totrait_name, and how. - Declared
Method - One method of a type, and the module whose source declares it.
- Declared
Test - One
test fn, and the module that declares it. - Enum
Entry - FnEntry
- A declaration that belongs to a module, with the facts derived from it.
- Program
- A resolved package, ready to run or inspect.
- Resolved
Module - Everything one module declares.
- Struct
Entry - Trait
Entry - A trait a module declares.
Enums§
- Call
Precision - How precisely a call site named the callee an edge leads to.
- FnKey
- A node in a module’s call graph: a free function or an
implmethod.
Functions§
- host_
modules - The host modules a package may name without declaring them.
- resolve
- Resolves every module of
packageinto the flat program the runtime executes. - resolve_
with - Resolves
packageagainstschemas, the host modules this compilation may name.
Type Aliases§
- Node
- One node of the package’s call graph: a declaration, and the module that declares it.