Composable sets of primitive Rust utility crates for fellow crustaceans.
use-diagnostic is a primitive diagnostic vocabulary set for RustUse. It provides small, reusable concepts for describing structured problems, warnings, validation issues, parse issues, configuration issues, and related notes.
This set is not an error framework, logging framework, renderer, CLI output system, compiler diagnostic system, or compiler frontend. It defines data primitives that other crates can compose without adopting a larger reporting model.
use-diagnostic: facade crate for the full diagnostic vocabulary setuse-diagnostic-code: stable diagnostic identifier primitivesuse-diagnostic-level: severity primitivesuse-diagnostic-message: human-facing plain-text message and note primitivesuse-diagnostic-span: generic source, position, and span primitivesuse-diagnostic-label: renderer-neutral labels attached to diagnosticsuse-diagnostic-report: simple insertion-order diagnostic collections and queries
use use_diagnostic::prelude::{
Diagnostic, DiagnosticCode, DiagnosticLabel, DiagnosticLevel, DiagnosticMessage,
DiagnosticPosition, DiagnosticReport, DiagnosticSpan,
};
let code = DiagnosticCode::new("VALIDATE_MISSING_FIELD").unwrap();
let message = DiagnosticMessage::new("missing required field").unwrap();
let start = DiagnosticPosition::new(3, 5).unwrap();
let end = DiagnosticPosition::new(3, 12).unwrap();
let span = DiagnosticSpan::without_source(start, end).unwrap();
let label = DiagnosticLabel::primary(
DiagnosticMessage::new("field is required 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());Diagnostics are useful vocabulary for sibling and future RustUse sets, including:
use-validateuse-configuse-datause-encodinguse-rustuse-cli
- Codes are stable string identifiers.
- Levels describe severity only.
- Messages and notes are plain text.
- Spans are generic source ranges, not filesystem or snippet renderers.
- Labels attach context without colors, terminal symbols, or source rendering.
- Reports are simple collections and query helpers.
Out of scope: logging, terminal rendering, panic hooks, global reporters, async processing, compiler-specific diagnostics, and replacement behavior for std::error::Error.
This workspace is a pre-1.0 RustUse primitive set. The first version keeps the API intentionally small so the concepts can stay durable as related sets adopt them.