`cfg_accessible` is not processed before derive macros
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#![feature(cfg_accessible)]
#[derive(Clone)]
#[cfg_accessible(std::nonexistent)]
struct Thing;
I expected the code to compile. Instead, I got the following error:
error[E0412]: cannot find type `Thing` in this scope
--> src/lib.rs:3:10
|
3 | #[derive(Clone)]
| ^^^^^ not found in this scope
error[E0425]: cannot find value `Thing` in this scope
--> src/lib.rs:3:10
|
3 | #[derive(Clone)]
| ^^^^^ not found in this scope
Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
Note that similar code using cfg instead of cfg_accessible compiles fine:
#![feature(cfg_accessible)]
#[derive(Clone)]
#[cfg(false)]
struct Thing;
From my testing, it seems that #[cfg] is processed before derive macros see the input. However, it is not processed before attribute macros see the input. However, cfg_accessible is treated as an attribute macros, and is processed from top-to-bottom along with other normal derive macros and attribute macros.
Meta
Reproducible on the playground with version 1.93.0-nightly (2025-11-04 f15a7f38580ddbdc1a23)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Reproduce the playground example with the reported nightly version, then trace how cfg_accessible is handled relative to derive and attribute macros. Done means the shown cfg_accessible example compiles as expected, matching the behavior observed with cfg.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100