Skip to main content

CheckInfo

Struct CheckInfo 

Source
pub struct CheckInfo {
Show 17 fields pub errors: Vec<String>, pub syntax_errors: usize, pub warnings: Vec<String>, pub deps: Vec<PathBuf>, pub closure_requires: Vec<(PathBuf, String)>, pub lints: Vec<String>, pub requires: Vec<RequireSite>, pub error_fixes: Vec<Option<Fix>>, pub lint_fixes: Vec<Option<Fix>>, pub dependency_errors: Vec<DependencyError>, pub error_items: Vec<Diagnostic>, pub warning_items: Vec<Diagnostic>, pub lint_items: Vec<Diagnostic>, pub global_sites: Vec<GlobalSite>, pub markers: Vec<MarkerSite>, pub record_sites: Vec<RecordSite>, pub types: TypeIndex,
}
Expand description

Result of type-checking one .tl file.

Fields§

§errors: Vec<String>

file:line:col: message for syntax and type errors.

§syntax_errors: usize

How many syntax errors the parser reported. Their text is in errors, worded however Teal’s parser words it (syntax error, expected ')', expected an expression, unexpected eof), so this count, and not the text, is what says the parser rejected the file.

§warnings: Vec<String>

file:line:col: message for warnings (non-fatal).

§deps: Vec<PathBuf>

Every file this check read through require (.tl / .d.tl / .lua): the file’s require closure, not only what it names itself. Sorted; the file itself is not in it, even when a cycle leads back to it.

The closure, because that is what the answer depends on. A check of top.tl that requires mid.tl walks mid.tl, whose require("host") walks host.d.tl: the globals host.d.tl declares are in scope in top.tl, and a record mid.tl re-exports from it (type Std = h.Std) is host.d.tl’s record when top.tl reads a field of it. Change host.d.tl and top.tl can report something else, though top.tl never names it. Every reader of this list wants that answer — the cache hashes it to decide whether a module’s recorded result still holds (the direct requires alone replayed top.tl’s old result over an edit to host.d.tl, #400), link::Linked::inputs hands it to cargo as the files to watch, and include_tl! tracks it for the same reason.

§closure_requires: Vec<(PathBuf, String)>

For every member of deps, the names that member required, as (member, name): the edges below the file, sorted by member, then name. A member’s names are its require sites — every require("<literal>") in it, resolved or not — each once; a member whose result carries no AST gives the names that resolved. The file’s own requires are requires, with their call sites.

What the cache probes besides the hashes of deps. A hash says a file that was read is unchanged; it cannot say that a name a member required still means that file. A mid.tl appearing where mid’s own require("host") now finds it instead of host.d.tl changes what top.tl sees exactly as an edit to host.d.tl does, and every file the old entry hashed still matches. So an entry asks each of these names again, from the member that asked it.

The sites and not only the resolved names, because a name that resolved nowhere is a question too. mid.tl’s require("gone") with no gone.tl leaves mid’s types unknown in top.tl; write gone.tl and mid.tl misses on its own requires, but top.tl hashes an unchanged mid.tl, and had the edge been left out it would replay the errors it recorded while gone was missing (#410). A name that later resolves, or resolves elsewhere, changes the answer to a question the entry asks.

§lints: Vec<String>

htl lint findings (nil-index, enum-exhaustive). Advisory unless the caller promotes them (htl check --strict, include_tl!).

§requires: Vec<RequireSite>

Every require("<literal>") in the file and where the checker resolved it. Input to require_cycles.

§error_fixes: Vec<Option<Fix>>

error_fixes[i] is the fix for errors[i], when the error has one.

§lint_fixes: Vec<Option<Fix>>

lint_fixes[i] is the fix for lints[i], when the lint has one.

§dependency_errors: Vec<DependencyError>

Type errors in the modules this check pulled in through require, transitively, each dependency once. Not in errors, and not what ok answers: the file itself checked, and generates; it is the require of that module that will raise at run time (Htl::install_searcher), which is why a caller reporting on a project treats these as errors too (htl check, include_tl!).

§error_items: Vec<Diagnostic>

errors, warnings and lints as the checker produced them, in their parts: error_items[i] is errors[i], its fix attached. What diagnostics hands out, so that no reader takes the text apart to learn a position, a rule or which class of error it is.

§warning_items: Vec<Diagnostic>§lint_items: Vec<Diagnostic>§global_sites: Vec<GlobalSite>

Every global declaration this check brought into scope, and where it is: the file’s own, and those of every module in its require closure. Input to global_redeclarations.

The closure and not the file alone, for two reasons the lint would otherwise miss the case it exists for. A .d.tl is never one of the files a directory check walks, so a global declared there would appear on no check; and a run whose files all replay from the cache builds no checker at all, so what a replayed check carries is all the run has. Each site once per check; the lint dedups across checks.

§markers: Vec<MarkerSite>

One entry per (marker, declaration) for htl’s nine markers ([crate::adopt::FEATURES]: struct, optional, sealed, extensible, nilable, contract, required, async, noyield) this check found on a declaration of the file, once each, ordered by line, then marker, then name, then kind — not by [crate::adopt::FEATURES] order. What [crate::adopt] counts to say how much of a project already writes a marker.

Empty for a .d.tl: htl dts writes ---@async / ---@noyield into a declaration itself, and this is a census of what the project’s own authors wrote.

§record_sites: Vec<RecordSite>

One entry per table literal this check found typed as a declared record and per as cast to one — marked ---@struct or ---@sealed or neither, whole or not — the input unmarked_structs and unmarked_sealeds group by declaration, and htl adopt’s ---@struct and ---@sealed rows (#304) read the same way. An inferred record (a bare { ... } with no declaration anywhere) is not one of these; see RecordSite::record_file.

Empty for a .d.tl, as CheckInfo::markers is: no literal or cast is built in a declaration file either.

§types: TypeIndex

The types and declarations of the file’s names, by position: what an editor asks for on hover and go-to-definition, and the tree of what the file declares for an outline (typeindex). Empty unless the check was Htl::check_indexed, which is the only one that copies it out of the checker.

Implementations§

Source§

impl CheckInfo

Source

pub fn type_at(&self, text: &str, line: usize, col: usize) -> Option<TypeAt>

Shorthand for TypeIndex::at on the index this check kept.

Source§

impl CheckInfo

Source

pub fn ok(&self) -> bool

true when nothing failed the check — errors only. Warnings and lints are the caller’s to promote (clean is the stricter question), so this is what decides whether generated code may be run.

Source

pub fn clean(&self) -> bool

true when there are no errors, warnings or lints.

Source

pub fn diagnostics(&self) -> Vec<Diagnostic>

Everything this check found about the file itself, structured, in the order the text output says it: warnings, then lints, then errors.

Errors in what the file required are not here — they belong to the module they are in, and it is the reporting caller that decides how to say them (dependency_errors).

Source

pub fn error_diagnostics(&self) -> Vec<Diagnostic>

errors with their positions, their class and their fixes.

Source

pub fn warning_diagnostics(&self) -> Vec<Diagnostic>

warnings with their positions and kinds. Warnings carry no fix.

Source

pub fn lint_diagnostics(&self) -> Vec<Diagnostic>

lints with their positions, their rule names and their fixes.

Trait Implementations§

Source§

impl Clone for CheckInfo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CheckInfo

Source§

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

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

impl Default for CheckInfo

Source§

fn default() -> Self

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.