From a8879cb4d9837ebea28da6e5c2e41e9dded65f3e Mon Sep 17 00:00:00 2001 From: SabrinaJewson Date: Wed, 27 Apr 2022 16:40:07 +0100 Subject: [PATCH] rust-format: Prevent accidental usage of _blank_ and _comment_ --- rust_format/src/lib.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rust_format/src/lib.rs b/rust_format/src/lib.rs index 9252ae0..be3aa44 100644 --- a/rust_format/src/lib.rs +++ b/rust_format/src/lib.rs @@ -79,8 +79,12 @@ const RUST_FMT_KEY: &str = "RUSTFMT"; #[cfg_attr(docsrs, doc(cfg(feature = "post_process")))] #[macro_export] macro_rules! _blank_ { - () => {}; - ($lit:literal) => {}; + () => { + ::core::compile_error!("The _blank_ macro is not meant to be invoked in code") + }; + ($lit:literal) => { + $crate::_blank_! {} + }; } /// A "marker" macro used to mark locations in the source code where comments should be inserted. @@ -98,8 +102,12 @@ macro_rules! _blank_ { #[cfg_attr(docsrs, doc(cfg(feature = "post_process")))] #[macro_export] macro_rules! _comment_ { - () => {}; - ($lit:literal) => {}; + () => { + ::core::compile_error!("The _comment_ macro is not meant to be invoked in code") + }; + ($lit:literal) => { + $crate::_comment_! {} + }; } // *** Error ***