Skip to main content

Program

Struct Program 

Source
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: Facts

What 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

Source

pub fn lookup_fn(&self, module: &str, name: &str) -> Option<&FnEntry>

Looks up a fully qualified entry such as hello.main.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Program

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Program

Source§

fn default() -> Program

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.