-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
A-cfgArea: `cfg` conditional compilationArea: `cfg` conditional compilationA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.F-cfg_accessible`#![feature(cfg_accessible)]``#![feature(cfg_accessible)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
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)
Metadata
Metadata
Assignees
Labels
A-cfgArea: `cfg` conditional compilationArea: `cfg` conditional compilationA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.F-cfg_accessible`#![feature(cfg_accessible)]``#![feature(cfg_accessible)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.