From 18341fd23a2221ef6d111d2072f9f8bcef3c6a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francis=20Gagn=C3=A9?= Date: Sun, 18 Mar 2018 14:09:07 -0400 Subject: [PATCH] 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. --- ci/dox.sh | 2 +- src/dox.rs | 4 ++-- src/lib.rs | 6 +++--- src/macros.rs | 4 ++-- src/unix/mod.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ci/dox.sh b/ci/dox.sh index 85e92439..b8ffa7dd 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -16,7 +16,7 @@ cp ci/landing-page-head.html target/doc/index.html for target in $TARGETS; do echo documenting $target - rustdoc -o target/doc/$target --target $target src/lib.rs --cfg dox \ + rustdoc -o target/doc/$target --target $target src/lib.rs --cfg cross_platform_docs \ --crate-name libc echo "
  • $target
  • " \ diff --git a/src/dox.rs b/src/dox.rs index 5c095b9c..1aea62d0 100644 --- a/src/dox.rs +++ b/src/dox.rs @@ -1,6 +1,6 @@ pub use self::imp::*; -#[cfg(not(dox))] +#[cfg(not(cross_platform_docs))] mod imp { pub use core::option::Option; pub use core::clone::Clone; @@ -8,7 +8,7 @@ mod imp { pub use core::mem; } -#[cfg(dox)] +#[cfg(cross_platform_docs)] mod imp { pub enum Option { Some(T), diff --git a/src/lib.rs b/src/lib.rs index e17bc50f..25554806 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,8 @@ #![allow(bad_style, overflowing_literals, improper_ctypes)] #![crate_type = "rlib"] #![crate_name = "libc"] -#![cfg_attr(dox, feature(no_core, lang_items))] -#![cfg_attr(dox, no_core)] +#![cfg_attr(cross_platform_docs, feature(no_core, lang_items))] +#![cfg_attr(cross_platform_docs, no_core)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] @@ -97,7 +97,7 @@ #![cfg_attr(not(feature = "use_std"), no_std)] -#[cfg(all(not(dox), feature = "use_std"))] +#[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; #[macro_use] mod macros; diff --git a/src/macros.rs b/src/macros.rs index 84294420..0e13bfcf 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -53,12 +53,12 @@ macro_rules! f { $($body:stmt);* })*) => ($( #[inline] - #[cfg(not(dox))] + #[cfg(not(cross_platform_docs))] pub unsafe extern fn $i($($arg: $argty),*) -> $ret { $($body);* } - #[cfg(dox)] + #[cfg(cross_platform_docs)] #[allow(dead_code)] pub unsafe extern fn $i($($arg: $argty),*) -> $ret { loop {} diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 134f44c5..d6cde7ae 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -269,7 +269,7 @@ pub const INADDR_BROADCAST: in_addr_t = 4294967295; pub const INADDR_NONE: in_addr_t = 4294967295; cfg_if! { - if #[cfg(dox)] { + if #[cfg(cross_platform_docs)] { // on dox builds don't pull in anything } else if #[cfg(target_os = "l4re")] { // required libraries for L4Re are linked externally, ATM