pub struct Diagnostic {
pub rule: Cow<'static, str>,
pub line: usize,
pub column: usize,
pub span: Range<usize>,
pub message: String,
pub fix: Option<Fix>,
pub advisory: bool,
}Expand description
One issue at one source location, optionally with an automatic
Fix. Spans are byte ranges into the original source string.
Fields§
§rule: Cow<'static, str>Kebab-case identifier of the rule that produced this
diagnostic. Cow so stdlib rules can borrow &'static str
names while user rules with runtime-built names own the buffer.
The dispatcher stamps this field after each rule’s check
returns, so rule implementations do not set it.
line: usize1-indexed line number of the diagnostic’s first byte.
column: usize1-indexed codepoint column.
span: Range<usize>Byte span within the source. source.get(span.clone()) is the
substring the diagnostic refers to.
message: StringOne-line human-readable message.
fix: Option<Fix>Optional replacement covering span.
advisory: boolWhether this diagnostic is advisory (informational; does not
fail --check). Set by the dispatcher from the rule’s
is_advisory().
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn at(
doc: &Document,
byte_offset: usize,
local: Range<usize>,
message: String,
fix: Option<Fix>,
) -> Option<Self>
pub fn at( doc: &Document, byte_offset: usize, local: Range<usize>, message: String, fix: Option<Fix>, ) -> Option<Self>
Build a diagnostic at a position within a borrowed source
slice. byte_offset is the absolute offset of the slice’s
first byte; local is the match range within that slice.
Returns None if the line-index lookup fails — never observed
for offsets produced by pulldown-cmark, but the safe-fallback
behaviour is to drop the diagnostic rather than panic.
The dispatcher fills in rule and advisory after the
containing rule’s check returns.
Sourcepub fn suppress_via(&self) -> String
pub fn suppress_via(&self) -> String
Suppression marker text. The Markdown comment for muting this
diagnostic on the next block is
<!-- mdwright: allow rule-name -->.
Sourcepub fn severity(&self) -> Severity
pub fn severity(&self) -> Severity
Diagnostic severity derived from Self::advisory. Used by
the v2 JSON Lines emitter and the rustc-style pretty header.
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 more