In #2307, I added an optional diagnostic code which prints out the lint name . Since the Diagnostic struct in stacks-core didn't have a field for this, I implemented a wrapper, LintDiagnostic around it. This is kind of messy, it leaves us with both Diagnostics and LintDiagnostics and requires special handling to make sure we check and output both sets of diagnostics. It would be better to add an optional feild to Diagnostic to handle this:
pub struct Diagnostic {
pub level: Level,
pub message: String,
pub spans: Vec<Span>,
pub suggestion: Option<String>,
pub code: Option<&'static str>, // Proposed addition
}
A &'static str should be fine because the set of diagnostic codes are fixed and known at compile time
In #2307, I added an optional diagnostic code which prints out the lint name . Since the
Diagnosticstruct in stacks-core didn't have a field for this, I implemented a wrapper,LintDiagnosticaround it. This is kind of messy, it leaves us with bothDiagnostics andLintDiagnostics and requires special handling to make sure we check and output both sets of diagnostics. It would be better to add an optional feild toDiagnosticto handle this:A
&'static strshould be fine because the set of diagnostic codes are fixed and known at compile time