rs_std_ext/
compile_warning.rs

1/// Emits a compile-time warning.
2///
3/// This works like the standard [`std::compile_error`] macro,
4/// but emits a warning instead of an error.
5///
6/// The error is actually a `dead_code`, since rust doesn't
7/// support emitting **real** warnings now.
8///
9/// **Note**
10///
11/// The macro expands to something like:
12///
13/// ```rust,ignore
14/// #[warn(dead_code)]
15/// const WARNING: &str = "<some warning>";
16/// ```
17///
18/// So the ident `WARNING` is reserved.
19/// If you want to override it, use the following syntax:
20///
21/// ```rust,ignore
22/// use rs_std_ext::compile_warning;
23///
24/// compile_warning!(MW: "warning");
25/// // this expand to
26/// // const MW: &str = "warning";
27/// ```
28#[macro_export]
29macro_rules! compile_warning {
30    ($text:expr) => {
31        #[warn(dead_code)]
32        const WARNING: &str = $text;
33    };
34    ($ident:ident: $text:expr) => {
35        #[warn(dead_code)]
36        const $ident: &str = $text;
37    };
38}