Skip to content

Commit 6fd31ae

Browse files
committed
Auto merge of #951 - FraGag:rename-dox-cfg, r=alexcrichton
Rename the dox configuration option to cross_platform_docs The libc crate is used as a dependency of the Rust compiler. Its build system passes `--cfg dox` to all crates when generating their documentation. libc's documentation is generated when the build system is asked to generate the compiler documentation because `cargo doc` automatically documents all dependencies. When the dox configuration option is enabled, libc disables its dependency on the core crate and provides the necessary definitions itself. The dox configuration option is meant for generating documentation for a multitude of targets even if the core crate for that target is not installed. However, when documenting the compiler, it's not necessary to do that; we can just use `core` or `std` as usual. This change is motivated by the changes made to the compiler in rust-lang/rust#48171. With these changes, it's necessary to provide implementations of the `Clone` and `Copy` traits for some primitive types in the library that defines these traits (previously, these implementations were provided by the compiler). Normally, these traits (and thus the implementations) are provided by core, so any crate that uses `#![no_core]` must now provide its own copy of the implementations. Because libc doesn't provide its own copy of the implementations yet, and because the compiler's build system passes `--cfg dox` to libc, generating the documentation for the compiler fails when generating documentation for libc. By renaming the configuration option, libc will use `core` or `std` and will thus have the necessary definitions for the documentation to be generated successfully. **Note:** rust-lang/rust#48171 is blocked on this PR and on a release of libc including this change on crates.io. (Some crates in the compiler use libc as a submodule, while others use a version from crates.io.)
2 parents 3e9ccfa + e1fd577 commit 6fd31ae

File tree

7 files changed

+66
-68
lines changed

7 files changed

+66
-68
lines changed

Cargo.lock

+56-58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "libc"
4-
version = "0.2.39"
4+
version = "0.2.40"
55
authors = ["The Rust Project Developers"]
66
license = "MIT/Apache-2.0"
77
readme = "README.md"

ci/dox.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cp ci/landing-page-head.html target/doc/index.html
1616
for target in $TARGETS; do
1717
echo documenting $target
1818

19-
rustdoc -o target/doc/$target --target $target src/lib.rs --cfg dox \
19+
rustdoc -o target/doc/$target --target $target src/lib.rs --cfg cross_platform_docs \
2020
--crate-name libc
2121

2222
echo "<li><a href="/libc/$target/libc/index.html">$target</a></li>" \

src/dox.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
pub use self::imp::*;
22

3-
#[cfg(not(dox))]
3+
#[cfg(not(cross_platform_docs))]
44
mod imp {
55
pub use core::option::Option;
66
pub use core::clone::Clone;
77
pub use core::marker::Copy;
88
pub use core::mem;
99
}
1010

11-
#[cfg(dox)]
11+
#[cfg(cross_platform_docs)]
1212
mod imp {
1313
pub enum Option<T> {
1414
Some(T),

src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#![allow(bad_style, overflowing_literals, improper_ctypes)]
1414
#![crate_type = "rlib"]
1515
#![crate_name = "libc"]
16-
#![cfg_attr(dox, feature(no_core, lang_items))]
17-
#![cfg_attr(dox, no_core)]
16+
#![cfg_attr(cross_platform_docs, feature(no_core, lang_items))]
17+
#![cfg_attr(cross_platform_docs, no_core)]
1818
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1919
html_favicon_url = "https://doc.rust-lang.org/favicon.ico")]
2020

@@ -97,7 +97,7 @@
9797

9898
#![cfg_attr(not(feature = "use_std"), no_std)]
9999

100-
#[cfg(all(not(dox), feature = "use_std"))]
100+
#[cfg(all(not(cross_platform_docs), feature = "use_std"))]
101101
extern crate std as core;
102102

103103
#[macro_use] mod macros;

src/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ macro_rules! f {
5353
$($body:stmt);*
5454
})*) => ($(
5555
#[inline]
56-
#[cfg(not(dox))]
56+
#[cfg(not(cross_platform_docs))]
5757
pub unsafe extern fn $i($($arg: $argty),*) -> $ret {
5858
$($body);*
5959
}
6060

61-
#[cfg(dox)]
61+
#[cfg(cross_platform_docs)]
6262
#[allow(dead_code)]
6363
pub unsafe extern fn $i($($arg: $argty),*) -> $ret {
6464
loop {}

src/unix/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pub const INADDR_BROADCAST: in_addr_t = 4294967295;
269269
pub const INADDR_NONE: in_addr_t = 4294967295;
270270

271271
cfg_if! {
272-
if #[cfg(dox)] {
272+
if #[cfg(cross_platform_docs)] {
273273
// on dox builds don't pull in anything
274274
} else if #[cfg(target_os = "l4re")] {
275275
// required libraries for L4Re are linked externally, ATM

0 commit comments

Comments
 (0)