| Crates.io | proc-diag |
| lib.rs | proc-diag |
| version | 0.2.0 |
| created_at | 2025-08-10 20:15:47.146526+00 |
| updated_at | 2025-08-11 21:44:40.14239+00 |
| description | Leverage compiler-provided functionality to emit custom error messages in procedural macros. |
| homepage | |
| repository | https://github.com/jhpratt/proc-diag |
| max_upload_size | |
| id | 1789262 |
| size | 23,915 |
Leverage compiler-provided functionality to emit custom error messages in procedural macros.
use proc_diag::Error;
Error::new("custom error message")
.label("inline label")
.note("some context")
.note("additional context")
.span(some_span) // or .span((start_span, end_span))
.to_tokens(&mut output);
error[E0277]: custom error message
--> src/main.rs:L:11
|
L | demo!("macro input");
| ^^^^^^^^^^^^^ inline label
|
= help: the trait `DiagnosticHack` is not implemented for `*const ()`
= note: some context
= note: additional context
note: required by a bound in `diagnostic_hack`
--> src/main.rs:L:5
|
L | demo!("macro input");
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `diagnostic_hack`
= note: this error originates in the macro `demo` (in Nightly builds, run with -Z macro-backtrace for more info)
This crate has three feature flags:
quote enables an implementation of quote::ToTokens. This also enables the proc-macro2
feature.proc-macro2 enables passing proc_macro2::Span and (proc_macro2::Span, proc_macro2::Span) to
the span method.msrv-1-78, which lowers the minimum supported Rust version from 1.85 to 1.78. The side
effect of enabling this is an additional (irrelevant) line in the diagnostic output.