Skip to content

Commit 709f4fe

Browse files
authored
Rollup merge of rust-lang#139868 - thaliaarchi:move-env-consts-pal, r=joboet
Move `pal::env` to `std::sys::env_consts` Combine the `std::env::consts` platform implementations as a single file. Use the Unix file as the base, since it has 28 entries, and fold the 8 singleton platforms into it. The Unix file was roughly grouped into Linux, Apple, BSD, and everything else, roughly in alphabetical order. Alphabetically order them to make it easier to maintain and discard the Unix-specific groups to generalize it to all platforms. I'd prefer to have no fallback implementation, as I consider it a bug; however TEEOS, Trusty, and Xous have no definitions here. Since they otherwise have `pal` abstractions, that indicates that there are several platforms without `pal` abstractions which are also missing here. To support unsupported, create a little macro to handle the fallback case and not introduce ordering between the `cfg`s like `cfg_if!`. I've named the module `std::sys::env_consts`, because they are used in `std::env::consts` and I intend to use the name `std::sys::env` for the combination of `Args` and `Vars`. cc `@joboet` `@ChrisDenton` Tracked in rust-lang#117276.
2 parents 2d4f113 + 93fa96c commit 709f4fe

File tree

27 files changed

+206
-203
lines changed

27 files changed

+206
-203
lines changed

Diff for: compiler/rustc_target/src/spec/base/linux_musl.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use crate::spec::{LinkSelfContainedDefault, TargetOptions, base, crt_objects};
22

33
pub(crate) fn opts() -> TargetOptions {
4-
let mut base = base::linux::opts();
5-
6-
base.env = "musl".into();
7-
base.pre_link_objects_self_contained = crt_objects::pre_musl_self_contained();
8-
base.post_link_objects_self_contained = crt_objects::post_musl_self_contained();
9-
base.link_self_contained = LinkSelfContainedDefault::InferredForMusl;
10-
11-
base
4+
TargetOptions {
5+
env: "musl".into(),
6+
pre_link_objects_self_contained: crt_objects::pre_musl_self_contained(),
7+
post_link_objects_self_contained: crt_objects::post_musl_self_contained(),
8+
link_self_contained: LinkSelfContainedDefault::InferredForMusl,
9+
..base::linux::opts()
10+
}
1211
}

Diff for: compiler/rustc_target/src/spec/base/linux_ohos.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use crate::spec::{TargetOptions, TlsModel, base};
22

33
pub(crate) fn opts() -> TargetOptions {
4-
let mut base = base::linux::opts();
5-
6-
base.env = "ohos".into();
7-
base.crt_static_default = false;
8-
base.tls_model = TlsModel::Emulated;
9-
base.has_thread_local = false;
10-
11-
base
4+
TargetOptions {
5+
env: "ohos".into(),
6+
crt_static_default: false,
7+
tls_model: TlsModel::Emulated,
8+
has_thread_local: false,
9+
..base::linux::opts()
10+
}
1211
}

Diff for: library/std/src/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ impl fmt::Debug for ArgsOs {
950950
/// Constants associated with the current target
951951
#[stable(feature = "env", since = "1.0.0")]
952952
pub mod consts {
953-
use crate::sys::env::os;
953+
use crate::sys::env_consts::os;
954954

955955
/// A string describing the architecture of the CPU that is currently in use.
956956
/// An example value may be: `"x86"`, `"arm"` or `"riscv64"`.

0 commit comments

Comments
 (0)