Skip to content

Commit dc004d4

Browse files
committed
rustc_target: Rename some target options to avoid tautology
`target.target_endian` -> `target.endian` `target.target_c_int_width` -> `target.c_int_width` `target.target_os` -> `target.os` `target.target_env` -> `target.env` `target.target_vendor` -> `target.vendor` `target.target_family` -> `target.os_family` `target.target_mcount` -> `target.mcount`
1 parent bf66988 commit dc004d4

File tree

114 files changed

+218
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+218
-243
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
9090

9191
// The function name varies on platforms.
9292
// See test/CodeGen/mcount.c in clang.
93-
let mcount_name = CString::new(cx.sess().target.target_mcount.as_str().as_bytes()).unwrap();
93+
let mcount_name = CString::new(cx.sess().target.mcount.as_str().as_bytes()).unwrap();
9494

9595
llvm::AddFunctionAttrStringValue(
9696
llfn,

compiler/rustc_codegen_llvm/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
176176
// should use dllimport for functions.
177177
if cx.use_dll_storage_attrs
178178
&& tcx.is_dllimport_foreign_item(instance_def_id)
179-
&& tcx.sess.target.target_env != "gnu"
179+
&& tcx.sess.target.env != "gnu"
180180
{
181181
unsafe {
182182
llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ unsafe fn configure_llvm(sess: &Session) {
9191
}
9292
}
9393

94-
if sess.target.target_os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
94+
if sess.target.os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
9595
add("-enable-emscripten-cxx-exceptions", false);
9696
}
9797

compiler/rustc_codegen_llvm/src/va_arg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn emit_direct_ptr_va_arg(
5252
let next = bx.inbounds_gep(addr, &[full_direct_size]);
5353
bx.store(next, va_list_addr, bx.tcx().data_layout.pointer_align.abi);
5454

55-
if size.bytes() < slot_size.bytes() && &*bx.tcx().sess.target.target_endian == "big" {
55+
if size.bytes() < slot_size.bytes() && &*bx.tcx().sess.target.endian == "big" {
5656
let adjusted_size = bx.cx().const_i32((slot_size.bytes() - size.bytes()) as i32);
5757
let adjusted = bx.inbounds_gep(addr, &[adjusted_size]);
5858
(bx.bitcast(adjusted, bx.cx().type_ptr_to(llty)), addr_align)
@@ -105,7 +105,7 @@ fn emit_aapcs_va_arg(
105105
let mut end = bx.build_sibling_block("va_arg.end");
106106
let zero = bx.const_i32(0);
107107
let offset_align = Align::from_bytes(4).unwrap();
108-
assert!(&*bx.tcx().sess.target.target_endian == "little");
108+
assert!(&*bx.tcx().sess.target.endian == "little");
109109

110110
let gr_type = target_ty.is_any_ptr() || target_ty.is_integral();
111111
let (reg_off, reg_top_index, slot_size) = if gr_type {

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn get_linker(
163163
// MSVC needs to link with the Store versions of the runtime libraries (vcruntime, msvcrt, etc).
164164
let t = &sess.target;
165165
if (flavor == LinkerFlavor::Msvc || flavor == LinkerFlavor::Lld(LldFlavor::Link))
166-
&& t.target_vendor == "uwp"
166+
&& t.vendor == "uwp"
167167
{
168168
if let Some(ref tool) = msvc_tool {
169169
let original_path = tool.path();
@@ -1236,7 +1236,7 @@ fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool {
12361236
Some(CrtObjectsFallback::Musl) => sess.crt_static(Some(crate_type)),
12371237
Some(CrtObjectsFallback::Mingw) => {
12381238
sess.host == sess.target
1239-
&& sess.target.target_vendor != "uwp"
1239+
&& sess.target.vendor != "uwp"
12401240
&& detect_self_contained_mingw(&sess)
12411241
}
12421242
// FIXME: Figure out cases in which WASM needs to link with a native toolchain.
@@ -1510,7 +1510,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
15101510
let base_cmd = get_linker(sess, path, flavor, crt_objects_fallback);
15111511
// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
15121512
// to the linker args construction.
1513-
assert!(base_cmd.get_args().is_empty() || sess.target.target_vendor == "uwp");
1513+
assert!(base_cmd.get_args().is_empty() || sess.target.vendor == "uwp");
15141514
let cmd = &mut *codegen_results.linker_info.to_linker(base_cmd, &sess, flavor, target_cpu);
15151515
let link_output_kind = link_output_kind(sess, crate_type);
15161516

@@ -2078,9 +2078,9 @@ fn are_upstream_rust_objects_already_included(sess: &Session) -> bool {
20782078

20792079
fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
20802080
let arch = &sess.target.arch;
2081-
let os = &sess.target.target_os;
2081+
let os = &sess.target.os;
20822082
let llvm_target = &sess.target.llvm_target;
2083-
if sess.target.target_vendor != "apple"
2083+
if sess.target.vendor != "apple"
20842084
|| !matches!(os.as_str(), "ios" | "tvos")
20852085
|| flavor != LinkerFlavor::Gcc
20862086
{

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'a> Linker for GccLinker<'a> {
320320
// any `#[link]` attributes in the `libc` crate, see #72782 for details.
321321
// FIXME: Switch to using `#[link]` attributes in the `libc` crate
322322
// similarly to other targets.
323-
if self.sess.target.target_os == "vxworks"
323+
if self.sess.target.os == "vxworks"
324324
&& matches!(
325325
output_kind,
326326
LinkOutputKind::StaticNoPicExe

compiler/rustc_codegen_ssa/src/traits/type_.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
5151
}
5252

5353
fn type_int(&self) -> Self::Type {
54-
match &self.sess().target.target_c_int_width[..] {
54+
match &self.sess().target.c_int_width[..] {
5555
"16" => self.type_i16(),
5656
"32" => self.type_i32(),
5757
"64" => self.type_i64(),
58-
width => bug!("Unsupported target_c_int_width: {}", width),
58+
width => bug!("Unsupported c_int_width: {}", width),
5959
}
6060
}
6161

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,15 +2601,14 @@ where
26012601
};
26022602

26032603
let target = &cx.tcx().sess.target;
2604-
let target_env_gnu_like = matches!(&target.target_env[..], "gnu" | "musl");
2605-
let win_x64_gnu =
2606-
target.target_os == "windows" && target.arch == "x86_64" && target.target_env == "gnu";
2604+
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl");
2605+
let win_x64_gnu = target.os == "windows" && target.arch == "x86_64" && target.env == "gnu";
26072606
let linux_s390x_gnu_like =
2608-
target.target_os == "linux" && target.arch == "s390x" && target_env_gnu_like;
2607+
target.os == "linux" && target.arch == "s390x" && target_env_gnu_like;
26092608
let linux_sparc64_gnu_like =
2610-
target.target_os == "linux" && target.arch == "sparc64" && target_env_gnu_like;
2609+
target.os == "linux" && target.arch == "sparc64" && target_env_gnu_like;
26112610
let linux_powerpc_gnu_like =
2612-
target.target_os == "linux" && target.arch == "powerpc" && target_env_gnu_like;
2611+
target.os == "linux" && target.arch == "powerpc" && target_env_gnu_like;
26132612
let rust_abi = matches!(sig.abi, RustIntrinsic | PlatformIntrinsic | Rust | RustCall);
26142613

26152614
// Handle safe Rust thin and fat pointers.

compiler/rustc_session/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,12 @@ pub const fn default_lib_output() -> CrateType {
735735
}
736736

737737
pub fn default_configuration(sess: &Session) -> CrateConfig {
738-
let end = &sess.target.target_endian;
738+
let end = &sess.target.endian;
739739
let arch = &sess.target.arch;
740740
let wordsz = sess.target.pointer_width.to_string();
741-
let os = &sess.target.target_os;
742-
let env = &sess.target.target_env;
743-
let vendor = &sess.target.target_vendor;
741+
let os = &sess.target.os;
742+
let env = &sess.target.env;
743+
let vendor = &sess.target.vendor;
744744
let min_atomic_width = sess.target.min_atomic_width();
745745
let max_atomic_width = sess.target.max_atomic_width();
746746
let atomic_cas = sess.target.atomic_cas;
@@ -752,7 +752,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
752752
ret.reserve(6); // the minimum number of insertions
753753
// Target bindings.
754754
ret.insert((sym::target_os, Some(Symbol::intern(os))));
755-
if let Some(ref fam) = sess.target.target_family {
755+
if let Some(ref fam) = sess.target.os_family {
756756
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
757757
if fam == "windows" {
758758
ret.insert((sym::windows, None));

compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
584584
"nvptx64" => nvptx64::compute_abi_info(self),
585585
"hexagon" => hexagon::compute_abi_info(self),
586586
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
587-
"wasm32" if cx.target_spec().target_os != "emscripten" => {
587+
"wasm32" if cx.target_spec().os != "emscripten" => {
588588
wasm32_bindgen_compat::compute_abi_info(self)
589589
}
590590
"wasm32" | "asmjs" => wasm32::compute_abi_info(cx, self),

0 commit comments

Comments
 (0)