Skip to content

Commit 4ac26af

Browse files
committed
Deprecate use_std cargo feature: use std instead .
Related to rust-lang#657 .
1 parent f775bea commit 4ac26af

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ appveyor = { repository = "rust-lang/libc", project_name = "rust-lang-libs/libc"
2323
rustc-std-workspace-core = { version = "1.0.0", optional = true }
2424

2525
[features]
26-
default = ["use_std"]
27-
use_std = []
26+
default = ["std"]
27+
std = []
2828
align = []
2929
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
3030
extra_traits = []
31+
# use_std is deprecated, use `std` instead
32+
use_std = [ 'std' ]
3133

3234
[workspace]
3335
members = ["libc-test"]

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ libc = "0.2"
2828

2929
## Features
3030

31-
* `use_std`: by default `libc` links to the standard library. Disable this
31+
* `std`: by default `libc` links to the standard library. Disable this
3232
feature remove this dependency and be able to use `libc` in `#![no_std]`
3333
crates.
3434

3535
* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`.
3636
This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`.
3737

38+
* **deprecated**: `use_std` is deprecated, and is equivalent to `std`.
39+
3840
## Rust version support
3941

4042
The minimum supported Rust toolchain version is **Rust 1.13.0** . APIs requiring

build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ fn main() {
99
std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
1010
let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();
1111

12+
if std::env::var("CARGO_FEATURE_USE_STD").is_ok() {
13+
println!(
14+
"cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \
15+
please consider using the `std` cargo feature instead\""
16+
);
17+
}
18+
1219
// Rust >= 1.15 supports private module use:
1320
if rustc_minor_ver >= 15 || rustc_dep_of_std {
1421
println!("cargo:rustc-cfg=libc_priv_mod_use");

libc-test/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ cc = "1.0"
1313
ctest = "0.2"
1414

1515
[features]
16-
default = [ "use_std" ]
17-
use_std = [ "libc/use_std" ]
16+
default = [ "std" ]
17+
std = [ "libc/std" ]
1818
align = [ "libc/align" ]
1919
extra_traits = [ "libc/extra_traits" ]
2020

src/unix/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub const ATF_USETRAILERS: ::c_int = 0x10;
307307
cfg_if! {
308308
if #[cfg(target_os = "l4re")] {
309309
// required libraries for L4Re are linked externally, ATM
310-
} else if #[cfg(feature = "use_std")] {
310+
} else if #[cfg(feature = "std")] {
311311
// cargo build, don't pull in anything extra as the libstd dep
312312
// already pulls in all libs.
313313
} else if #[cfg(target_env = "musl")] {

0 commit comments

Comments
 (0)