codespan-derive
Derive macro for ergonomically creating a Diagnostic from an error macro
Usage
- Add
#[derive(IntoDiagnostic)]onto your error macro type. - Add a
#[file_id(Type)]to signal what theFileIdgeneric type of theDiagnosticwill be. - Tag every variant with a
#[message = ""]signalling what the error message should read. - Span-like values that implement
IntoLabelcan be tagged with#[primary]or#[secondary]to be marked in the generated error, with an optional message like#[primary = ""].
Then handle it somewhere like:
if let Some = result