This is unfortunately requires an unstable feature: see rust-lang/rust#54140
In other crates:
proc-macro-error emits such diagnostics on nightly but silently ignores them on stable
proc-macro2-diagnostics converts such diagnostics to errors when not on nightly. (Unfortunately it has a poor design for emitting a non-fatal diagnostic and continuing macro parsing/expansion.)