According to its own readme, the proc-macro-hack crate was superseded by native support for #[proc_macro] in expression position in Rust 1.45. Besides that, proc-macro-hack is known to cause issues with rust-analyzer, a popular language server for Rust. A somewhat important consequence of these issues is that using the const_random macro makes Rust Analyzer yield an spurious "unresolved macro" error, which is annoying.
To improve on this situation without explicitly bumping MSRV, let's use native rustc support when available. This can slightly modify the macro hygiene, although I didn't notice any glaring difference.
According to its own readme, the proc-macro-hack crate was superseded by native support for
#[proc_macro]
in expression position in Rust 1.45. Besides that, proc-macro-hack is known to cause issues with rust-analyzer, a popular language server for Rust. A somewhat important consequence of these issues is that using theconst_random
macro makes Rust Analyzer yield an spurious "unresolved macro" error, which is annoying.To improve on this situation without explicitly bumping MSRV, let's use native rustc support when available. This can slightly modify the macro hygiene, although I didn't notice any glaring difference.
Related Rust Analyzer project issues and PRs: https://github.com/rust-analyzer/rust-analyzer/issues/7221 https://github.com/rust-analyzer/rust-analyzer/pull/9128