macro_rules! const_warn {
($msg:literal $(,)?) => { ... };
(if $cond:expr, $msg:literal $(,)?) => { ... };
(%if $cond:expr, $name:ident, $msg:literal $(,)?) => { ... };
}Expand description
โ ๐ Emits a compile-time warning with a provided message.
๐ code/util
ยงExample
fn main() {
const_warn!("hello warning!");
const_warn!(if size_of::<u8>() == 1, "byte alert!!");
}That may look as follows:
warning: use of deprecated associated constant `main::_::__::<true>::WARNING`: hello warning!
--> src/main.rs:3:5
|
3 | const_warn!("hello warning!");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
= note: this warning originates in the macro `$crate::const_warn` which comes from the expansion of the macro `const_warn` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: use of deprecated associated constant `main::_::__::<true>::WARNING`: byte alert!!
--> src/main.rs:4:5
|
4 | const_warn!(if size_of::<u8>() == 1, "byte alert!!");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...