How do I print all attributes?

Viewed 178

I want to print the compile-time attributes to the console, ("conditional predicates"). Is there built-in function or macro that does this?

I'm imagining code like:

#[allow(non_snake_case)]
fn main() {
    eprintln!(cfg_as_str!());
}

that might print

allow.non_snake_case=true
allow.dead_code=false
...
cfg.debug_attributes=true
cfg.test=false
cfg.bench=false
...
target_arch="x86_64"
...

I want to better understand the state of the rust compiler at different lines of code. However, it's tedious to do so by trial-and-error.

Of course, I could write this on my own. But I'd guess someone else already has.

1 Answers
Related