Expand description
§use-diagnostic
Facade crate for RustUse diagnostic primitives.
use-diagnostic reexports the focused crates in the diagnostic set. It is a primitive vocabulary for codes, levels, messages, spans, labels, diagnostics, and reports.
It is not an error framework, logging framework, terminal renderer, CLI output system, or compiler diagnostic system.
§Reexports
use_diagnostic_codeuse_diagnostic_leveluse_diagnostic_messageuse_diagnostic_spanuse_diagnostic_labeluse_diagnostic_report
§Example
use use_diagnostic::prelude::{
Diagnostic, DiagnosticCode, DiagnosticLabel, DiagnosticLevel, DiagnosticMessage,
DiagnosticPosition, DiagnosticReport, DiagnosticSpan,
};
let code = DiagnosticCode::new("DATA.INVALID_SHAPE").unwrap();
let message = DiagnosticMessage::new("invalid data shape").unwrap();
let start = DiagnosticPosition::new(8, 3).unwrap();
let end = DiagnosticPosition::new(8, 11).unwrap();
let span = DiagnosticSpan::without_source(start, end).unwrap();
let label = DiagnosticLabel::primary(
DiagnosticMessage::new("expected an object here").unwrap(),
span,
);
let diagnostic = Diagnostic::new(DiagnosticLevel::Error, message)
.with_code(code)
.with_label(label);
let mut report = DiagnosticReport::new();
report.add(diagnostic);
assert!(report.has_errors());§Scope
The facade keeps implementation minimal. It provides reexports and a shared prelude only.
§Status
use-diagnostic is a pre-1.0 facade for the focused diagnostic primitive crates.
Re-exports§
pub use use_diagnostic_code as code;pub use use_diagnostic_label as label;pub use use_diagnostic_level as level;pub use use_diagnostic_message as message;pub use use_diagnostic_report as report;pub use use_diagnostic_span as span;
Modules§
Structs§
- Diagnostic
- A structured diagnostic data value.
- Diagnostic
Code - A stable string identifier for a diagnostic.
- Diagnostic
Label - Renderer-neutral context attached to a diagnostic.
- Diagnostic
Level Parse Error - Error returned when parsing a diagnostic level fails.
- Diagnostic
Message - A human-facing diagnostic message.
- Diagnostic
Note - Additional plain-text context attached to a diagnostic.
- Diagnostic
Position - A 1-based line and column position.
- Diagnostic
Report - An insertion-order collection of diagnostics.
- Diagnostic
Source Id - A stable identifier for a source, file, buffer, document, or virtual source.
- Diagnostic
Span - A generic source span with optional source identity.
Enums§
- Diagnostic
Code Error - Errors returned while constructing a
DiagnosticCode. - Diagnostic
Label Kind - The role of a diagnostic label.
- Diagnostic
Level - The severity level of a diagnostic.
- Diagnostic
Position Error - Errors returned while constructing a
DiagnosticPosition. - Diagnostic
Source IdError - Errors returned while constructing a
DiagnosticSourceId. - Diagnostic
Span Error - Errors returned while constructing a
DiagnosticSpan. - Diagnostic
Text Error - Errors returned while constructing diagnostic text primitives.