Rust proc macros - how to detect enabled features

81 Views Asked by At

Since Rust proc macro code runs at compile time, I'm assuming what is normally conditional compilation, is accessible at the macro's runtime.

How do I access it? (for example, maybe I only want to parse certain syntax if a given feature is enabled)

For context - what I'm trying to do is parse an identifier - but a conditionally compiled one. My LSP errors out, though actually compiling library consumers works fine. Closest thing I could find was "CARGO_FEATURE_" in the rust docs, but that's only for build scripts.

0

There are 0 best solutions below