Skip to main content

Diagnostic

Struct Diagnostic 

Source
pub struct Diagnostic {
    pub severity: Severity,
    pub file: String,
    pub line: usize,
    pub col: usize,
    pub rule: Option<String>,
    pub message: String,
    pub fix: Option<Fix>,
    pub required_by: Option<String>,
    pub origin: Option<String>,
}
Expand description

One error: / warning: / lint: finding, split into its parts.

The serialized form is what htl check --format json prints. Field names are stable; new fields may be added, existing ones are not renamed.

Fields§

§severity: Severity

Which of the three this is, and so whether a run that reported it fails — the caller’s to decide for a warning or a lint, settled for an error.

§file: String

The file the diagnostic is in, as the report spells it. Empty when the text carried no position (a failure that is about a file rather than a place in one).

§line: usize

The line, counted from 1 as the checker counts it. 0 alongside an empty file: the text carried no position, rather than pointing at a first line.

§col: usize

The column, counted from 1, and 0 under the same condition as line.

§rule: Option<String>

The lint rule (nil-index, contract, …) for lint diagnostics, or a Teal warning’s kind (tl:unused, …) for a warning, kept apart from the message. On an error the checker raised it is the class htl fix files that error’s fix under (forward-ref, tl:error), the same name htl fix --format json gives it.

§message: String

What the finding says, with the position prefix and the [htl <rule>] suffix taken off — the sentence alone, so a reader that formats its own line does not have to unpick one.

§fix: Option<Fix>

A mechanical rewrite htl fix may apply, when the diagnostic has one.

§required_by: Option<String>

For an error in a module the check reached through require: the file whose require pulled it in. Absent on the project’s own diagnostics.

§origin: Option<String>

Where such a file lives: dependency (installed under .htl/modules, a vendored copy, or the declarations a crate ships under types/<crate>/) or external (a [check] paths or contract directory). Absent for a file of the project’s own, a patched dependency included, and on the project’s own diagnostics. Decided by the module whose directory holds the file (crate::model::Owner::origin), the same module htl resolve names a file’s origin from.

Implementations§

Source§

impl Diagnostic

Source

pub fn new( severity: Severity, file: impl Into<String>, line: usize, col: usize, message: impl Into<String>, rule: Option<&str>, ) -> Diagnostic

A finding made by htl rather than read from the checker: file as the report should spell it, the 1-based position, the sentence alone, and the rule it is said under (None for an error that is not a lint’s). fix, required_by and origin start empty.

Source

pub fn spelled(self) -> Diagnostic

The same finding with its paths — file and required_by — spelled as every report spells a path (display_path). The checker names a file as it was handed it (./src/a.tl, or absolute from a search path); a reader that prints a diagnostic takes it through here first, so a failed include_tl!, a junit body and htl check name one file one way.

Source

pub fn parse(severity: Severity, text: &str) -> Diagnostic

"<file>:<line>:<col>: <message>" — what the checker formats — into its parts. Text that is not in that shape keeps the whole of itself as the message, with no file and no position.

fix, required_by and origin are the caller’s to fill in: they are not in the text, they travel beside it.

Trait Implementations§

Source§

impl Clone for Diagnostic

Source§

fn clone(&self) -> Diagnostic

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 Diagnostic

Source§

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

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

impl Display for Diagnostic

The text form, and the only place it is made: <file>:<line>:<col>: <message>, the position left out when there is none, and [htl <rule>] after a warning’s or a lint’s message. An error’s rule is the class its fix is filed under and is not printed: the text of an error has never carried one.

Every line htl prints about a finding comes from here, whether the finding was just made or read back from the store, so the two cannot drift apart.

Source§

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

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

impl Eq for Diagnostic

Source§

impl PartialEq for Diagnostic

Source§

fn eq(&self, other: &Diagnostic) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Diagnostic

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Diagnostic

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.