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

Make documentation clear about conditional compilation use #15494

Closed
Qantas94Heavy opened this issue Jul 7, 2014 · 4 comments · Fixed by #16189
Closed

Make documentation clear about conditional compilation use #15494

Qantas94Heavy opened this issue Jul 7, 2014 · 4 comments · Fixed by #16189

Comments

@Qantas94Heavy
Copy link

From what I read of the documentation, only whole items/modules/crates can be processed through conditional compilation.

Static entities in Rust — crates, modules and items — may have attributes applied to them.

Though this is not in the documentation, this seems to work:

fn main() {
    println!("{}", Blue as int);
    println!("{}", Green as int);
}

enum Color {
  Red = 0xff0000,
  #[cfg(windows)]
  Green = 0x00ff00,
  Blue = 0x0000ff
}

As expected, the compiler throws an error (on Linux):

<anon>:3:20: 3:25 error: unresolved name Green.

However, it's not clear in the documentation what is the scope of the attribute in this instance. Have I got my idea of what is an item wrong, or is this merely an oversight in the documentation?

@huonw huonw added the A-docs label Jul 7, 2014
@sfackler
Copy link
Member

sfackler commented Jul 7, 2014

It's an oversight in the documentation. The set of placed attribute have been allowed has slowly expanded and the documentation hasn't kept up.

@steveklabnik
Copy link
Member

Which documentation says this? I'd like to fix it.

@sfackler
Copy link
Member

sfackler commented Jul 7, 2014

@steveklabnik
Copy link
Member

Ahh yes. The manual certainly needs lots of improvement. I'd welcome a fix to this section, if nobody else gets to it, I will at some point.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Aug 2, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants