-
Notifications
You must be signed in to change notification settings - Fork 723
feature-gate most Nix functions #1611
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
Conversation
Using features reduces build time and size for consumer crates. By default all features are enabled.
|
Supersedes #1498 . I'm creating a new PR rather than update the previous one because I didn't want to erase some of its history by force-pushing. |
e4c3179 to
771c710
Compare
|
bors r+ |
| O_LARGEFILE; | ||
| /// Do not update the file last access time during `read(2)`s. | ||
| #[cfg(any(target_os = "android", target_os = "linux"))] | ||
| #[cfg_attr(docsrs, doc(cfg(all())))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @asomers, looking at our source code, I am curious why this #[cfg_attr(docsrs, doc(cfg(all())))] is needed?
From my obervation:
-
We are not enabling the
doc_auto_cfgfeature, which means we won't get a#[doc(cfg(xx))]with#[cfg(xxx)], so no need to overwrite a non-existing value -
The
doc_cfgfeature does not seem to work with assocaiated item:// src/lib.rs #![feature(doc_cfg)] #[cfg(target_os = "linux")] #[doc(cfg(target_os = "linux"))] pub struct Foo; impl Foo { #[cfg(target_os = "linux")] #[doc(cfg(target_os = "linux"))] pub const LINUX_SPECIFIC_CONST: usize = 1; }
Run:
$ cargo +nightly doc --target x86_64-unknown-linux-gnu --open
That
Available on Linux only.banner will be set forFooonly, not forLINUX_SPECIFIC_CONST
And some types in our code are partially annocated with this attribute, e.g., enum Request defined in src/sys/ptrace/linux.rs, which makes me confused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they're there because I originally developed the PR with the doc_auto_cfg feature (see 83ea2f3). When that's on, constants like O_NOCTTY get a "This is supported on non-Redox only" banner. Those banners are both annoyingly verbose and deceptive (see the linked commit message for the explanation for why they're deceptive). But then I must've removed doc_auto_cfg before I posted the PR, leaving the doc(cfg(all())) attributes useless. So we can remove them now.
Using features reduces build time and size for consumer crates. By
default all features are enabled.