I ran into this issue when trying to disable ASAN instrumentation, without breaking stable users (in an attempt to fix dtolnay/inventory#90). Since ASAN is unstable, and detecting if ASAN is enabled is also unstable, the easiest solution is to require users to set a custom cfg.
#[allow(unexpected_cfgs)]
#[cfg_attr(asan, sanitize(address = "off"))]
static MY_ITEM: () = ();
mod my_mod {
#![allow(unexpected_cfgs)]
#[cfg_attr(asan, sanitize(address = "off"))]
static MY_ITEM: () = ();
}
The code in question is intended to be generated by a macro in user crates, so requiring all (existing) users to silence the lint, just so that ASAN works again is maybe too much to ask and it would be preferable if the macro could silence the lint, but it appears there is no way to do that.
Originally posted by @jschwe in #124735
Originally posted by @jschwe in #124735