Skip to main content

Program

Struct Program 

Source
pub struct Program {
    pub db: FileDb,
    pub graph: Option<Graph>,
    pub roots: Vec<Root>,
    pub runs: bool,
    pub diagnostics: Vec<Diagnostic>,
}
Expand description

What to load (spec §4.4).

Fields§

§db: FileDb

Every manifest the graph read. The loader adds every source file.

§graph: Option<Graph>

None for a loose program, or when the root’s manifest cannot be read or parsed.

§roots: Vec<Root>

The entry first.

§runs: bool

Whether MIR runs: the entry is src/main.nova, or a loose file.

§diagnostics: Vec<Diagnostic>

The graph’s diagnostics.

Implementations§

Source§

impl Program

Source

pub fn loose(path: &Path) -> Program

A loose program: path, and the files beside it that it imports.

Source

pub fn for_file(path: &Path) -> Program

The program whose entry is path (spec §4.1). It is a module of its package when it is directly in a package’s src/ or tests/, and otherwise loose, reading no manifest.

Source

pub fn for_package(root: &Path, roots: Roots) -> Program

The package whose nova.toml is in root (empty for the current directory), with the roots roots names that exist.

Source

pub fn for_package_in(root: &Path, roots: Roots, offline: &Offline) -> Program

Program::for_package, with registry packages found as offline says (spec 3.3b §5.4): tests pass the registry directory, and publishing’s verification reads no dev-dependencies.

Source

pub fn doc_tests(package: Option<&Path>, paths: Vec<PathBuf>) -> Program

A program of doc tests (spec 3.5b §5, §6.2), each of paths a RootKind::Doc root, read through the Sources given to build_test_program_with: of the package whose nova.toml is in package, or of no package for std’s (None).

A package’s library, src/lib.nova, is a root after them. The loader then reads it under the path the root names, as nova doc‘s analysis does, rather than the one an import names, which differs on Windows under an empty root; a diagnostic’s map finds the library in the database by that name (spec 3.5b §7). The first doc test stays the entry, which names the binary apart from the unit tests’.

With no paths there is no root, and a build fails with “nothing to compile” rather than build the library’s own tests.

Source

pub fn has_errors(&self) -> bool

Whether the graph found an error.

Source

pub fn manifest(&self) -> Option<FileId>

The root package’s nova.toml in db, once read. The language server publishes the graph’s problems under it (spec §6).

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more