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

Special case behavior of #![cfg(..)] at crate root needs documenting #34968

Closed
pnkfelix opened this issue Jul 21, 2016 · 1 comment
Closed

Special case behavior of #![cfg(..)] at crate root needs documenting #34968

pnkfelix opened this issue Jul 21, 2016 · 1 comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@pnkfelix
Copy link
Member

Spawned off of #34932 (comment)

If you put the inner attribute #![cfg(..)] at a crate root, this (apparently) causes an empty crate to be generated. I.e., it is as if the crate itself still exists, but all of its contents have disappeared.

This is slightly different than the behavior of #![cfg(..)] elsewhere (e.g. in a mod item), where such an inner attribute will cause the whole item to be omitted from the AST, rather than just causing the contents of the item to be omitted.

I don't see any mention of this corner case in the Rust documentation for Conditional Compilation, here: https://doc.rust-lang.org/book/conditional-compilation.html

@steveklabnik steveklabnik added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Mar 10, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 25, 2017
@QuietMisdreavus
Copy link
Member

Since the second edition of the book doesn't have a dedicated section to conditional compilation, I'm moving the issue to the reference repo: rust-lang/reference#103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants