pub struct Program {
pub modules: BTreeMap<String, ResolvedModule>,
pub notices: Vec<Diagnostic>,
pub call_graph: BTreeMap<Node, BTreeMap<Node, CallPrecision>>,
pub facts: Facts,
}Expand description
A resolved package, ready to run or inspect.
Fields§
§modules: BTreeMap<String, ResolvedModule>§notices: Vec<Diagnostic>Every diagnostic that does not stop the package: the resolver’s own warnings, such as a missing doc comment on an exported declaration, and the type checker’s warnings and notes.
It is called notices rather than warnings because it holds two
severities and they ask for different things. A warning is a doubt,
and cove check --deny-warnings refuses a package that has one. A
note is not: it is the compiler naming something it deliberately did
not prove — a Host API result a schema declared Any, a variadic
operation used as a value — which no strictness setting can turn into
a proof. Every consumer therefore filters on the exact
cove_diag::Severity rather than on this field’s length.
It never holds an cove_diag::Severity::Error: an error is
returned as Err and the package does not resolve.
call_graph: BTreeMap<Node, BTreeMap<Node, CallPrecision>>The package’s call graph: for each declaration, every declaration it may call, and how precisely the call site named it.
This is the graph FnEntry::required_capabilities is the fixed
point over. It is kept rather than discarded because reachability
between declarations is a derived fact in its own right: it is what
answers which declarations a change can affect.
facts: FactsWhat the type checker worked out about each expression: its type, and for a call to a declared method, which declaration it chose.
Resolution settles no types, so this is filled by the check rather
than here: Compiler::compile
runs both halves and puts the second one’s answers here, and a
program that was only resolved carries none. ADR 0019 is why it is
carried at all — a pass that re-derives a fact the checker already
settled is a pass that can disagree with it.
Implementations§
Source§impl Program
impl Program
Sourcepub fn lookup_fn(&self, module: &str, name: &str) -> Option<&FnEntry>
pub fn lookup_fn(&self, module: &str, name: &str) -> Option<&FnEntry>
Looks up a fully qualified entry such as hello.main.
Sourcepub fn tests(&self) -> Vec<DeclaredTest<'_>>
pub fn tests(&self) -> Vec<DeclaredTest<'_>>
Every test fn the package declares, in module then name order.
This is what cove test runs. A test is an ordinary declaration of
its module, so its required capabilities are already derived and its
body already checked; the runner only has to find it.
Sourcepub fn conformances_of(
&self,
type_module: &str,
type_name: &str,
) -> Vec<(&str, &Conformance)>
pub fn conformances_of( &self, type_module: &str, type_name: &str, ) -> Vec<(&str, &Conformance)>
Every conformance declared for the type type_module.type_name,
paired with the module whose source declares it, in trait order.
The declaring module is not always the type’s own. ADR 0006’s orphan
rule only requires that the module declaring an impl Trait for Type
block declares one of the two, so a conformance may be written where
the trait is. A type’s conformances are therefore a fact about the
package, and asking one module for them under-reports the type’s
interface.
Sourcepub fn methods_of(
&self,
type_module: &str,
type_name: &str,
) -> Vec<DeclaredMethod<'_>>
pub fn methods_of( &self, type_module: &str, type_name: &str, ) -> Vec<DeclaredMethod<'_>>
Every method of the type type_module.type_name, wherever it is
declared, in method-name order.
A type’s methods usually live in the module that declares the type. A
conformance is the exception, for the reason Self::conformances_of
gives: a method of this type can be declared by any module that
conforms it to a trait of its own.
One name answers to one method, whichever module declares it:
check_method_collisions rejects a package where two modules
declare a method of one name for one type.