Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfg_attr doesn't work in all contexts #19372

Closed
sfackler opened this issue Nov 28, 2014 · 4 comments · Fixed by #22116
Closed

cfg_attr doesn't work in all contexts #19372

sfackler opened this issue Nov 28, 2014 · 4 comments · Fixed by #22116
Assignees
Labels
A-syntaxext Area: Syntax extensions

Comments

@sfackler
Copy link
Member

It's implemented as a syntax extension, so it only works when attached to an item. It should really be folded into the strip_cfg pass until syntax extensions are powerful enough to handle all the cases.

@sfackler sfackler added the A-syntaxext Area: Syntax extensions label Nov 28, 2014
@huonw
Copy link
Member

huonw commented Jan 6, 2015

@sfackler is this fixed by #18634?

@sfackler
Copy link
Member Author

sfackler commented Jan 6, 2015

Not entirely. It's still not going to handle attributes on patterns, fields, or variants AFAIKT.

@kmcallister kmcallister self-assigned this Feb 8, 2015
kmcallister added a commit to kmcallister/rust that referenced this issue Feb 9, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this issue Feb 10, 2015
@SergioBenitez
Copy link
Contributor

This doesn't appear to be fixed when cfg_attr is used inside of a macro:

macro_rules! borked {
    () => {
        #[derive(Debug)] pub struct Good;
        #[cfg_attr(not(test), derive(Debug))] pub struct Bad;
    }
}

borked!();

fn main() {
    println!("{:?}", Good);
    println!("{:?}", Bad);
}

(via curmet @ IRC)

@kmcallister
Copy link
Contributor

Thanks, I've opened #22250 about that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants