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: SeverityWhich 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: StringThe 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: usizeThe 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: usizeThe 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: StringWhat 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
impl Diagnostic
Sourcepub fn new(
severity: Severity,
file: impl Into<String>,
line: usize,
col: usize,
message: impl Into<String>,
rule: Option<&str>,
) -> Diagnostic
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.
Sourcepub fn spelled(self) -> Diagnostic
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.
Sourcepub fn parse(severity: Severity, text: &str) -> Diagnostic
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
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Diagnostic
impl Debug for Diagnostic
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.
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.
impl Eq for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
Source§impl Serialize for Diagnostic
impl Serialize for Diagnostic
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnsafeUnpin for Diagnostic
impl UnwindSafe for Diagnostic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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