1

In a Rust program, it is possible to emit a compiler error and halt the translation machinery, for example:

macro_rules! a {
  ($name:ident) => {println!("{}", name)};
  ($exp:expr) => {compile_error!("Do not use an expression.")};
}

Is there a similar macro to emit a compile-time warning? I'm using the syn crate and have through the documentation, but couldn't find any reference.

The only thing I can find in the documentation are a series of nightly-only APIs, which won't work for my use case because I can't use a nightly release.

Teymour
  • 1,832
  • 1
  • 13
  • 34
  • Does [this](https://stackoverflow.com/questions/56741004/how-can-i-display-a-compiler-warning-upon-function-invocation/56798246#56798246) answer you question? As far as I know, abusing those attributes is the only way at the moment. – mcarton Jun 18 '20 at 10:22

0 Answers0