From 0df84cdc4979e53dbeb1620b8db1096a16271a85 Mon Sep 17 00:00:00 2001 From: jam1garner <8260240+jam1garner@users.noreply.github.com> Date: Fri, 1 Apr 2022 01:29:38 -0400 Subject: [PATCH 01/10] Don't emit non-asm contents error for naked function composed of errors --- compiler/rustc_passes/src/naked_functions.rs | 25 +++++++++++++++++--- src/test/ui/asm/naked-functions.rs | 13 ++++++++++ src/test/ui/asm/naked-functions.stderr | 14 ++++++++++- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index 00a93ccc9aa..cd966df119f 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -147,7 +147,7 @@ impl<'tcx> Visitor<'tcx> for CheckParameters<'tcx> { fn check_asm<'tcx>(tcx: TyCtxt<'tcx>, body: &'tcx hir::Body<'tcx>, fn_span: Span) { let mut this = CheckInlineAssembly { tcx, items: Vec::new() }; this.visit_body(body); - if let [(ItemKind::Asm, _)] = this.items[..] { + if let [(ItemKind::Asm | ItemKind::Err, _)] = this.items[..] { // Ok. } else { let mut diag = struct_span_err!( @@ -156,19 +156,33 @@ fn check_asm<'tcx>(tcx: TyCtxt<'tcx>, body: &'tcx hir::Body<'tcx>, fn_span: Span E0787, "naked functions must contain a single asm block" ); + + let mut must_show_error = false; let mut has_asm = false; + let mut has_err = false; for &(kind, span) in &this.items { match kind { ItemKind::Asm if has_asm => { + must_show_error = true; diag.span_label(span, "multiple asm blocks are unsupported in naked functions"); } ItemKind::Asm => has_asm = true, ItemKind::NonAsm => { + must_show_error = true; diag.span_label(span, "non-asm is unsupported in naked functions"); } + ItemKind::Err => has_err = true, } } - diag.emit(); + + // If the naked function only contains a single asm block and a non-zero number of + // errors, then don't show an additional error. This allows for appending/prepending + // `compile_error!("...")` statements and reduces error noise. + if must_show_error || !has_err { + diag.emit(); + } else { + diag.cancel(); + } } } @@ -181,6 +195,7 @@ struct CheckInlineAssembly<'tcx> { enum ItemKind { Asm, NonAsm, + Err, } impl<'tcx> CheckInlineAssembly<'tcx> { @@ -222,9 +237,13 @@ impl<'tcx> CheckInlineAssembly<'tcx> { self.check_inline_asm(asm, span); } - ExprKind::DropTemps(..) | ExprKind::Block(..) | ExprKind::Err => { + ExprKind::DropTemps(..) | ExprKind::Block(..) => { hir::intravisit::walk_expr(self, expr); } + + ExprKind::Err => { + self.items.push((ItemKind::Err, span)); + } } } diff --git a/src/test/ui/asm/naked-functions.rs b/src/test/ui/asm/naked-functions.rs index 9c6e810dfce..a8fd24a3e07 100644 --- a/src/test/ui/asm/naked-functions.rs +++ b/src/test/ui/asm/naked-functions.rs @@ -196,3 +196,16 @@ pub unsafe extern "C" fn inline_never() { pub unsafe extern "C" fn inline_all() { asm!("", options(noreturn)); } + +#[naked] +pub unsafe extern "C" fn allow_compile_error(a: u32) -> u32 { + compile_error!("this is a user specified error") + //~^ ERROR this is a user specified error +} + +#[naked] +pub unsafe extern "C" fn allow_compile_error_and_asm(a: u32) -> u32 { + compile_error!("this is a user specified error"); + //~^ ERROR this is a user specified error + asm!("", options(noreturn)) +} diff --git a/src/test/ui/asm/naked-functions.stderr b/src/test/ui/asm/naked-functions.stderr index 5520f815f3e..32eae1f37a3 100644 --- a/src/test/ui/asm/naked-functions.stderr +++ b/src/test/ui/asm/naked-functions.stderr @@ -4,6 +4,18 @@ error: asm with the `pure` option must have at least one output LL | asm!("", options(readonly, nostack), options(pure)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ +error: this is a user specified error + --> $DIR/naked-functions.rs:202:5 + | +LL | compile_error!("this is a user specified error") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this is a user specified error + --> $DIR/naked-functions.rs:208:5 + | +LL | compile_error!("this is a user specified error"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: patterns not allowed in naked function parameters --> $DIR/naked-functions.rs:20:5 | @@ -255,6 +267,6 @@ error: naked functions cannot be inlined LL | #[inline(never)] | ^^^^^^^^^^^^^^^^ -error: aborting due to 30 previous errors; 2 warnings emitted +error: aborting due to 32 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0787`. From bf26d87df669d706c7897ca168c04bdeefb78bc5 Mon Sep 17 00:00:00 2001 From: jam1garner <8260240+jam1garner@users.noreply.github.com> Date: Fri, 1 Apr 2022 12:24:04 -0400 Subject: [PATCH 02/10] Add regression test for naked functions with invalid asm syntax --- src/test/ui/asm/naked-functions.rs | 6 ++++++ src/test/ui/asm/naked-functions.stderr | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/ui/asm/naked-functions.rs b/src/test/ui/asm/naked-functions.rs index a8fd24a3e07..2a57afa1a6a 100644 --- a/src/test/ui/asm/naked-functions.rs +++ b/src/test/ui/asm/naked-functions.rs @@ -209,3 +209,9 @@ pub unsafe extern "C" fn allow_compile_error_and_asm(a: u32) -> u32 { //~^ ERROR this is a user specified error asm!("", options(noreturn)) } + +#[naked] +pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 { + asm!(invalid_syntax) + //~^ ERROR asm template must be a string literal +} diff --git a/src/test/ui/asm/naked-functions.stderr b/src/test/ui/asm/naked-functions.stderr index 32eae1f37a3..7bbe49c3b19 100644 --- a/src/test/ui/asm/naked-functions.stderr +++ b/src/test/ui/asm/naked-functions.stderr @@ -16,6 +16,12 @@ error: this is a user specified error LL | compile_error!("this is a user specified error"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: asm template must be a string literal + --> $DIR/naked-functions.rs:215:10 + | +LL | asm!(invalid_syntax) + | ^^^^^^^^^^^^^^ + error: patterns not allowed in naked function parameters --> $DIR/naked-functions.rs:20:5 | @@ -267,6 +273,6 @@ error: naked functions cannot be inlined LL | #[inline(never)] | ^^^^^^^^^^^^^^^^ -error: aborting due to 32 previous errors; 2 warnings emitted +error: aborting due to 33 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0787`. From 78698dd0fbdf7772fca2b203ae262de00e268f37 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Apr 2022 13:40:43 +0200 Subject: [PATCH 03/10] Fix display of attributes in rustdoc --- src/librustdoc/html/render/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 93b33b0d609..42d818e20a8 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1002,7 +1002,12 @@ fn attributes(it: &clean::Item) -> Vec { .iter() .filter_map(|attr| { if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) { - Some(pprust::attribute_to_string(attr).replace('\n', "").replace(" ", " ")) + Some( + pprust::attribute_to_string(attr) + .replace("\\\n", "") + .replace('\n', "") + .replace(" ", " "), + ) } else { None } From 995513c92986713a3a8260d8944e5ed82755347b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Apr 2022 13:41:12 +0200 Subject: [PATCH 04/10] Add test for attribute display in rustdoc --- src/test/rustdoc/attribute-rendering.rs | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/test/rustdoc/attribute-rendering.rs diff --git a/src/test/rustdoc/attribute-rendering.rs b/src/test/rustdoc/attribute-rendering.rs new file mode 100644 index 00000000000..6777871846e --- /dev/null +++ b/src/test/rustdoc/attribute-rendering.rs @@ -0,0 +1,7 @@ +#![crate_name = "foo"] + +// @has 'foo/fn.f.html' +// @has - //*[@'class="docblock item-decl"]' '#[export_name = "f"] pub fn f()' +#[export_name = "\ +f"] +pub fn f() {} From 9d4d5a4eeb7d01e34e18490baeae7a68642c316c Mon Sep 17 00:00:00 2001 From: Adam Sandberg Ericsson Date: Sun, 3 Apr 2022 19:03:34 +0100 Subject: [PATCH 05/10] core: document that the align_of* functions return the alignment in bytes --- library/core/src/mem/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 005f8749e01..0d33fea75f4 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -383,7 +383,7 @@ pub const unsafe fn size_of_val_raw(val: *const T) -> usize { unsafe { intrinsics::size_of_val(val) } } -/// Returns the [ABI]-required minimum alignment of a type. +/// Returns the [ABI]-required minimum alignment of a type in bytes. /// /// Every reference to a value of the type `T` must be a multiple of this number. /// @@ -407,7 +407,8 @@ pub fn min_align_of() -> usize { intrinsics::min_align_of::() } -/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. +/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in +/// bytes. /// /// Every reference to a value of the type `T` must be a multiple of this number. /// @@ -430,7 +431,7 @@ pub fn min_align_of_val(val: &T) -> usize { unsafe { intrinsics::min_align_of_val(val) } } -/// Returns the [ABI]-required minimum alignment of a type. +/// Returns the [ABI]-required minimum alignment of a type in bytes. /// /// Every reference to a value of the type `T` must be a multiple of this number. /// @@ -454,7 +455,8 @@ pub const fn align_of() -> usize { intrinsics::min_align_of::() } -/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. +/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in +/// bytes. /// /// Every reference to a value of the type `T` must be a multiple of this number. /// @@ -477,7 +479,8 @@ pub const fn align_of_val(val: &T) -> usize { unsafe { intrinsics::min_align_of_val(val) } } -/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. +/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in +/// bytes. /// /// Every reference to a value of the type `T` must be a multiple of this number. /// From ccff48f97b7a4438b9818f8ff0f60c1cd01cdbeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BRANSTETT?= Date: Tue, 22 Mar 2022 11:43:05 +0100 Subject: [PATCH 06/10] Replace every `String` in Target(Options) with `Cow<'static, str>` --- compiler/rustc_codegen_llvm/src/attributes.rs | 2 +- compiler/rustc_codegen_llvm/src/builder.rs | 2 +- compiler/rustc_codegen_llvm/src/context.rs | 4 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 2 +- compiler/rustc_codegen_llvm/src/llvm_util.rs | 10 +- compiler/rustc_codegen_ssa/src/back/link.rs | 16 +- compiler/rustc_codegen_ssa/src/back/linker.rs | 4 +- compiler/rustc_codegen_ssa/src/back/write.rs | 4 +- compiler/rustc_metadata/src/locator.rs | 12 +- compiler/rustc_serialize/src/json.rs | 7 + .../src/spec/aarch64_apple_darwin.rs | 12 +- .../src/spec/aarch64_apple_ios.rs | 10 +- .../src/spec/aarch64_apple_ios_macabi.rs | 10 +- .../src/spec/aarch64_apple_ios_sim.rs | 10 +- .../src/spec/aarch64_apple_tvos.rs | 8 +- .../src/spec/aarch64_be_unknown_linux_gnu.rs | 10 +- .../aarch64_be_unknown_linux_gnu_ilp32.rs | 12 +- .../rustc_target/src/spec/aarch64_fuchsia.rs | 6 +- .../src/spec/aarch64_kmc_solid_asp3.rs | 10 +- .../src/spec/aarch64_linux_android.rs | 8 +- .../src/spec/aarch64_pc_windows_msvc.rs | 8 +- .../src/spec/aarch64_unknown_freebsd.rs | 6 +- .../src/spec/aarch64_unknown_hermit.rs | 8 +- .../src/spec/aarch64_unknown_linux_gnu.rs | 10 +- .../spec/aarch64_unknown_linux_gnu_ilp32.rs | 12 +- .../src/spec/aarch64_unknown_linux_musl.rs | 8 +- .../src/spec/aarch64_unknown_netbsd.rs | 8 +- .../src/spec/aarch64_unknown_none.rs | 10 +- .../spec/aarch64_unknown_none_softfloat.rs | 12 +- .../src/spec/aarch64_unknown_openbsd.rs | 6 +- .../src/spec/aarch64_unknown_redox.rs | 6 +- .../src/spec/aarch64_unknown_uefi.rs | 8 +- .../src/spec/aarch64_uwp_windows_msvc.rs | 6 +- .../src/spec/aarch64_wrs_vxworks.rs | 6 +- .../rustc_target/src/spec/android_base.rs | 2 +- compiler/rustc_target/src/spec/apple_base.rs | 22 +-- .../rustc_target/src/spec/apple_sdk_base.rs | 19 ++- .../src/spec/arm_linux_androideabi.rs | 10 +- .../src/spec/arm_unknown_linux_gnueabi.rs | 12 +- .../src/spec/arm_unknown_linux_gnueabihf.rs | 12 +- .../src/spec/arm_unknown_linux_musleabi.rs | 12 +- .../src/spec/arm_unknown_linux_musleabihf.rs | 12 +- .../src/spec/armebv7r_none_eabi.rs | 10 +- .../src/spec/armebv7r_none_eabihf.rs | 12 +- .../src/spec/armv4t_unknown_linux_gnueabi.rs | 12 +- .../src/spec/armv5te_unknown_linux_gnueabi.rs | 12 +- .../spec/armv5te_unknown_linux_musleabi.rs | 12 +- .../spec/armv5te_unknown_linux_uclibceabi.rs | 12 +- .../src/spec/armv6_unknown_freebsd.rs | 14 +- .../src/spec/armv6_unknown_netbsd_eabihf.rs | 14 +- .../src/spec/armv6k_nintendo_3ds.rs | 32 ++-- .../rustc_target/src/spec/armv7_apple_ios.rs | 10 +- .../src/spec/armv7_linux_androideabi.rs | 12 +- .../src/spec/armv7_unknown_freebsd.rs | 14 +- .../src/spec/armv7_unknown_linux_gnueabi.rs | 12 +- .../src/spec/armv7_unknown_linux_gnueabihf.rs | 12 +- .../src/spec/armv7_unknown_linux_musleabi.rs | 12 +- .../spec/armv7_unknown_linux_musleabihf.rs | 12 +- .../spec/armv7_unknown_linux_uclibceabi.rs | 14 +- .../spec/armv7_unknown_linux_uclibceabihf.rs | 14 +- .../src/spec/armv7_unknown_netbsd_eabihf.rs | 14 +- .../src/spec/armv7_wrs_vxworks_eabihf.rs | 10 +- .../src/spec/armv7a_kmc_solid_asp3_eabi.rs | 10 +- .../src/spec/armv7a_kmc_solid_asp3_eabihf.rs | 10 +- .../rustc_target/src/spec/armv7a_none_eabi.rs | 12 +- .../src/spec/armv7a_none_eabihf.rs | 12 +- .../rustc_target/src/spec/armv7r_none_eabi.rs | 10 +- .../src/spec/armv7r_none_eabihf.rs | 12 +- .../rustc_target/src/spec/armv7s_apple_ios.rs | 8 +- .../src/spec/asmjs_unknown_emscripten.rs | 2 +- .../rustc_target/src/spec/avr_gnu_base.rs | 18 +-- .../src/spec/avr_unknown_gnu_atmega328.rs | 2 +- .../src/spec/bpfeb_unknown_none.rs | 6 +- .../src/spec/bpfel_unknown_none.rs | 6 +- compiler/rustc_target/src/spec/crt_objects.rs | 9 +- .../rustc_target/src/spec/dragonfly_base.rs | 4 +- .../rustc_target/src/spec/freebsd_base.rs | 4 +- .../rustc_target/src/spec/fuchsia_base.rs | 28 ++-- compiler/rustc_target/src/spec/haiku_base.rs | 4 +- compiler/rustc_target/src/spec/hermit_base.rs | 6 +- .../src/spec/hexagon_unknown_linux_musl.rs | 10 +- .../rustc_target/src/spec/i386_apple_ios.rs | 8 +- .../src/spec/i386_unknown_linux_gnu.rs | 4 +- .../src/spec/i486_unknown_linux_gnu.rs | 4 +- .../src/spec/i586_pc_windows_msvc.rs | 4 +- .../src/spec/i586_unknown_linux_gnu.rs | 4 +- .../src/spec/i586_unknown_linux_musl.rs | 4 +- .../src/spec/i686_apple_darwin.rs | 12 +- .../src/spec/i686_linux_android.rs | 10 +- .../src/spec/i686_pc_windows_gnu.rs | 15 +- .../src/spec/i686_pc_windows_msvc.rs | 12 +- .../src/spec/i686_unknown_freebsd.rs | 12 +- .../src/spec/i686_unknown_haiku.rs | 10 +- .../src/spec/i686_unknown_linux_gnu.rs | 10 +- .../src/spec/i686_unknown_linux_musl.rs | 12 +- .../src/spec/i686_unknown_netbsd.rs | 12 +- .../src/spec/i686_unknown_openbsd.rs | 12 +- .../src/spec/i686_unknown_uefi.rs | 10 +- .../src/spec/i686_uwp_windows_gnu.rs | 13 +- .../src/spec/i686_uwp_windows_msvc.rs | 8 +- .../rustc_target/src/spec/i686_wrs_vxworks.rs | 10 +- .../rustc_target/src/spec/illumos_base.rs | 12 +- compiler/rustc_target/src/spec/l4re_base.rs | 8 +- compiler/rustc_target/src/spec/linux_base.rs | 4 +- .../rustc_target/src/spec/linux_gnu_base.rs | 2 +- .../src/spec/linux_kernel_base.rs | 2 +- .../rustc_target/src/spec/linux_musl_base.rs | 2 +- .../src/spec/linux_uclibc_base.rs | 2 +- .../src/spec/m68k_unknown_linux_gnu.rs | 8 +- .../src/spec/mips64_openwrt_linux_musl.rs | 14 +- .../src/spec/mips64_unknown_linux_gnuabi64.rs | 14 +- .../spec/mips64_unknown_linux_muslabi64.rs | 14 +- .../spec/mips64el_unknown_linux_gnuabi64.rs | 14 +- .../spec/mips64el_unknown_linux_muslabi64.rs | 12 +- .../src/spec/mips_unknown_linux_gnu.rs | 12 +- .../src/spec/mips_unknown_linux_musl.rs | 12 +- .../src/spec/mips_unknown_linux_uclibc.rs | 12 +- .../rustc_target/src/spec/mipsel_sony_psp.rs | 22 +-- .../src/spec/mipsel_unknown_linux_gnu.rs | 12 +- .../src/spec/mipsel_unknown_linux_musl.rs | 12 +- .../src/spec/mipsel_unknown_linux_uclibc.rs | 12 +- .../src/spec/mipsel_unknown_none.rs | 12 +- .../src/spec/mipsisa32r6_unknown_linux_gnu.rs | 12 +- .../spec/mipsisa32r6el_unknown_linux_gnu.rs | 12 +- .../mipsisa64r6_unknown_linux_gnuabi64.rs | 14 +- .../mipsisa64r6el_unknown_linux_gnuabi64.rs | 14 +- compiler/rustc_target/src/spec/mod.rs | 137 +++++++++--------- .../rustc_target/src/spec/msp430_none_elf.rs | 12 +- compiler/rustc_target/src/spec/msvc_base.rs | 2 +- compiler/rustc_target/src/spec/netbsd_base.rs | 4 +- .../src/spec/nvptx64_nvidia_cuda.rs | 20 +-- .../rustc_target/src/spec/openbsd_base.rs | 4 +- .../src/spec/powerpc64_unknown_freebsd.rs | 12 +- .../src/spec/powerpc64_unknown_linux_gnu.rs | 12 +- .../src/spec/powerpc64_unknown_linux_musl.rs | 12 +- .../src/spec/powerpc64_wrs_vxworks.rs | 10 +- .../src/spec/powerpc64le_unknown_freebsd.rs | 12 +- .../src/spec/powerpc64le_unknown_linux_gnu.rs | 12 +- .../spec/powerpc64le_unknown_linux_musl.rs | 12 +- .../src/spec/powerpc_unknown_freebsd.rs | 14 +- .../src/spec/powerpc_unknown_linux_gnu.rs | 10 +- .../src/spec/powerpc_unknown_linux_gnuspe.rs | 12 +- .../src/spec/powerpc_unknown_linux_musl.rs | 10 +- .../src/spec/powerpc_unknown_netbsd.rs | 10 +- .../src/spec/powerpc_unknown_openbsd.rs | 6 +- .../src/spec/powerpc_wrs_vxworks.rs | 12 +- .../src/spec/powerpc_wrs_vxworks_spe.rs | 14 +- compiler/rustc_target/src/spec/redox_base.rs | 6 +- .../src/spec/riscv32gc_unknown_linux_gnu.rs | 12 +- .../src/spec/riscv32gc_unknown_linux_musl.rs | 12 +- .../src/spec/riscv32i_unknown_none_elf.rs | 10 +- .../src/spec/riscv32im_unknown_none_elf.rs | 12 +- .../src/spec/riscv32imac_unknown_none_elf.rs | 12 +- .../src/spec/riscv32imc_esp_espidf.rs | 20 +-- .../src/spec/riscv32imc_unknown_none_elf.rs | 12 +- .../src/spec/riscv64gc_unknown_freebsd.rs | 12 +- .../src/spec/riscv64gc_unknown_linux_gnu.rs | 12 +- .../src/spec/riscv64gc_unknown_linux_musl.rs | 12 +- .../src/spec/riscv64gc_unknown_none_elf.rs | 14 +- .../src/spec/riscv64imac_unknown_none_elf.rs | 12 +- .../src/spec/s390x_unknown_linux_gnu.rs | 10 +- .../src/spec/s390x_unknown_linux_musl.rs | 10 +- .../rustc_target/src/spec/solaris_base.rs | 4 +- compiler/rustc_target/src/spec/solid_base.rs | 4 +- .../src/spec/sparc64_unknown_linux_gnu.rs | 8 +- .../src/spec/sparc64_unknown_netbsd.rs | 12 +- .../src/spec/sparc64_unknown_openbsd.rs | 10 +- .../src/spec/sparc_unknown_linux_gnu.rs | 10 +- .../src/spec/sparcv9_sun_solaris.rs | 12 +- compiler/rustc_target/src/spec/thumb_base.rs | 2 +- .../src/spec/thumbv4t_none_eabi.rs | 18 +-- .../src/spec/thumbv6m_none_eabi.rs | 10 +- .../src/spec/thumbv7a_pc_windows_msvc.rs | 14 +- .../src/spec/thumbv7a_uwp_windows_msvc.rs | 8 +- .../src/spec/thumbv7em_none_eabi.rs | 8 +- .../src/spec/thumbv7em_none_eabihf.rs | 10 +- .../src/spec/thumbv7m_none_eabi.rs | 8 +- .../src/spec/thumbv7neon_linux_androideabi.rs | 12 +- .../thumbv7neon_unknown_linux_gnueabihf.rs | 10 +- .../thumbv7neon_unknown_linux_musleabihf.rs | 12 +- .../src/spec/thumbv8m_base_none_eabi.rs | 10 +- .../src/spec/thumbv8m_main_none_eabi.rs | 8 +- .../src/spec/thumbv8m_main_none_eabihf.rs | 10 +- .../rustc_target/src/spec/uefi_msvc_base.rs | 10 +- .../rustc_target/src/spec/vxworks_base.rs | 14 +- .../src/spec/wasm32_unknown_emscripten.rs | 29 ++-- .../src/spec/wasm32_unknown_unknown.rs | 18 +-- compiler/rustc_target/src/spec/wasm32_wasi.rs | 10 +- .../src/spec/wasm64_unknown_unknown.rs | 18 +-- compiler/rustc_target/src/spec/wasm_base.rs | 12 +- .../rustc_target/src/spec/windows_gnu_base.rs | 43 +++--- .../src/spec/windows_msvc_base.rs | 18 +-- .../src/spec/windows_uwp_gnu_base.rs | 26 ++-- .../src/spec/windows_uwp_msvc_base.rs | 6 +- .../src/spec/x86_64_apple_darwin.rs | 16 +- .../rustc_target/src/spec/x86_64_apple_ios.rs | 8 +- .../src/spec/x86_64_apple_ios_macabi.rs | 6 +- .../src/spec/x86_64_apple_tvos.rs | 6 +- .../src/spec/x86_64_fortanix_unknown_sgx.rs | 6 +- .../rustc_target/src/spec/x86_64_fuchsia.rs | 8 +- .../src/spec/x86_64_linux_android.rs | 12 +- .../src/spec/x86_64_pc_solaris.rs | 12 +- .../src/spec/x86_64_pc_windows_gnu.rs | 16 +- .../src/spec/x86_64_pc_windows_msvc.rs | 8 +- .../src/spec/x86_64_sun_solaris.rs | 12 +- .../src/spec/x86_64_unknown_dragonfly.rs | 10 +- .../src/spec/x86_64_unknown_freebsd.rs | 10 +- .../src/spec/x86_64_unknown_haiku.rs | 10 +- .../src/spec/x86_64_unknown_hermit.rs | 10 +- .../src/spec/x86_64_unknown_illumos.rs | 10 +- .../src/spec/x86_64_unknown_l4re_uclibc.rs | 8 +- .../src/spec/x86_64_unknown_linux_gnu.rs | 10 +- .../src/spec/x86_64_unknown_linux_gnux32.rs | 12 +- .../src/spec/x86_64_unknown_linux_musl.rs | 10 +- .../src/spec/x86_64_unknown_netbsd.rs | 12 +- .../src/spec/x86_64_unknown_none.rs | 12 +- .../spec/x86_64_unknown_none_linuxkernel.rs | 13 +- .../src/spec/x86_64_unknown_openbsd.rs | 10 +- .../src/spec/x86_64_unknown_redox.rs | 10 +- .../src/spec/x86_64_unknown_uefi.rs | 10 +- .../src/spec/x86_64_uwp_windows_gnu.rs | 14 +- .../src/spec/x86_64_uwp_windows_msvc.rs | 8 +- .../src/spec/x86_64_wrs_vxworks.rs | 10 +- 223 files changed, 1252 insertions(+), 1243 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 101da0012cb..c098ce36f02 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -116,7 +116,7 @@ fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribu // The function name varies on platforms. // See test/CodeGen/mcount.c in clang. - let mcount_name = cx.sess().target.mcount.as_str(); + let mcount_name = cx.sess().target.mcount.as_ref(); Some(llvm::CreateAttrStringValue( cx.llcx, diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index c4eb593d297..1bbfc13e05e 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -1452,7 +1452,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> { } fn fptoint_sat_broken_in_llvm(&self) -> bool { - match self.tcx.sess.target.arch.as_str() { + match self.tcx.sess.target.arch.as_ref() { // FIXME - https://bugs.llvm.org/show_bug.cgi?id=50083 "riscv64" => llvm_util::get_version() < (13, 0, 0), _ => false, diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 712431ca9ae..98cf873ebbd 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -134,7 +134,7 @@ pub unsafe fn create_module<'ll>( let mod_name = SmallCStr::new(mod_name); let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx); - let mut target_data_layout = sess.target.data_layout.clone(); + let mut target_data_layout = sess.target.data_layout.to_string(); let llvm_version = llvm_util::get_version(); if llvm_version < (13, 0, 0) { if sess.target.arch == "powerpc64" { @@ -859,7 +859,7 @@ impl<'ll> CodegenCx<'ll, '_> { // This isn't an "LLVM intrinsic", but LLVM's optimization passes // recognize it like one and we assume it exists in `core::slice::cmp` - match self.sess().target.arch.as_str() { + match self.sess().target.arch.as_ref() { "avr" | "msp430" => ifn!("memcmp", fn(i8p, i8p, t_isize) -> t_i16), _ => ifn!("memcmp", fn(i8p, i8p, t_isize) -> t_i32), } diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index fe149b4c8c2..f4dc33452d1 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -329,7 +329,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { let b_ptr = self.bitcast(b, i8p_ty); let n = self.const_usize(layout.size().bytes()); let cmp = self.call_intrinsic("memcmp", &[a_ptr, b_ptr, n]); - match self.cx.sess().target.arch.as_str() { + match self.cx.sess().target.arch.as_ref() { "avr" | "msp430" => self.icmp(IntPredicate::IntEQ, cmp, self.const_i16(0)), _ => self.icmp(IntPredicate::IntEQ, cmp, self.const_i32(0)), } diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index abcdb81c0e2..c24e369ae72 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -61,8 +61,8 @@ unsafe fn configure_llvm(sess: &Session) { full_arg.trim().split(|c: char| c == '=' || c.is_whitespace()).next().unwrap_or("") } - let cg_opts = sess.opts.cg.llvm_args.iter(); - let tg_opts = sess.target.llvm_args.iter(); + let cg_opts = sess.opts.cg.llvm_args.iter().map(AsRef::as_ref); + let tg_opts = sess.target.llvm_args.iter().map(AsRef::as_ref); let sess_args = cg_opts.chain(tg_opts); let user_specified_args: FxHashSet<_> = @@ -375,8 +375,10 @@ fn handle_native(name: &str) -> &str { } pub fn target_cpu(sess: &Session) -> &str { - let name = sess.opts.cg.target_cpu.as_ref().unwrap_or(&sess.target.cpu); - handle_native(name) + match sess.opts.cg.target_cpu { + Some(ref name) => handle_native(name), + None => handle_native(sess.target.cpu.as_ref()), + } } /// The list of LLVM features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`, diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 548ae0e411d..8b31d24b071 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -675,10 +675,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( linker::disable_localization(&mut cmd); for &(ref k, ref v) in &sess.target.link_env { - cmd.env(k, v); + cmd.env(k.as_ref(), v.as_ref()); } for k in &sess.target.link_env_remove { - cmd.env_remove(k); + cmd.env_remove(k.as_ref()); } if sess.opts.prints.contains(&PrintRequest::LinkArgs) { @@ -1216,7 +1216,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { if let Some(ret) = infer_from( sess, - sess.target.linker.clone().map(PathBuf::from), + sess.target.linker.as_ref().map(|l| PathBuf::from(l.as_ref())), Some(sess.target.linker_flavor), ) { return ret; @@ -1602,7 +1602,7 @@ fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_ty let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-"); let path = tmpdir.join(file_name); - if let Err(e) = fs::write(&path, script) { + if let Err(e) = fs::write(&path, script.as_ref()) { sess.fatal(&format!("failed to write link script to {}: {}", path.display(), e)); } @@ -1960,8 +1960,8 @@ fn add_order_independent_options( cmd.arg(&codegen_results.crate_info.target_cpu); cmd.arg("--cpu-features"); cmd.arg(match &sess.opts.cg.target_feature { - feat if !feat.is_empty() => feat, - _ => &sess.target.options.features, + feat if !feat.is_empty() => feat.as_ref(), + _ => sess.target.options.features.as_ref(), }); } @@ -2478,12 +2478,12 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { let os = &sess.target.os; let llvm_target = &sess.target.llvm_target; if sess.target.vendor != "apple" - || !matches!(os.as_str(), "ios" | "tvos") + || !matches!(os.as_ref(), "ios" | "tvos") || flavor != LinkerFlavor::Gcc { return; } - let sdk_name = match (arch.as_str(), os.as_str()) { + let sdk_name = match (arch.as_ref(), os.as_ref()) { ("aarch64", "tvos") => "appletvos", ("x86_64", "tvos") => "appletvsimulator", ("arm", "ios") => "iphoneos", diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 3a66bfafaf3..2c15ed83167 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -75,7 +75,7 @@ pub fn get_linker<'a>( if let Some(ref tool) = msvc_tool { let original_path = tool.path(); if let Some(ref root_lib_path) = original_path.ancestors().nth(4) { - let arch = match t.arch.as_str() { + let arch = match t.arch.as_ref() { "x86_64" => Some("x64"), "x86" => Some("x86"), "aarch64" => Some("arm64"), @@ -1520,7 +1520,7 @@ impl<'a> L4Bender<'a> { pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec { if let Some(ref exports) = tcx.sess.target.override_export_symbols { - return exports.clone(); + return exports.iter().map(ToString::to_string).collect(); } let mut symbols = Vec::new(); diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index d4eaf6389df..9417874ffb4 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -218,7 +218,7 @@ impl ModuleConfig { false ), emit_obj, - bc_cmdline: sess.target.bitcode_llvm_cmdline.clone(), + bc_cmdline: sess.target.bitcode_llvm_cmdline.to_string(), verify_llvm_ir: sess.verify_llvm_ir(), no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes, @@ -1061,7 +1061,7 @@ fn start_executing_work( is_pe_coff: tcx.sess.target.is_like_windows, target_can_use_split_dwarf: tcx.sess.target_can_use_split_dwarf(), target_pointer_width: tcx.sess.target.pointer_width, - target_arch: tcx.sess.target.arch.clone(), + target_arch: tcx.sess.target.arch.to_string(), debuginfo: tcx.sess.opts.debuginfo, split_debuginfo: tcx.sess.split_debuginfo(), split_dwarf_kind: tcx.sess.opts.debugging_opts.split_dwarf_kind, diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index 2204b44e3a1..43bda7c0734 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -416,10 +416,10 @@ impl<'a> CrateLocator<'a> { (&f[rlib_prefix.len()..(f.len() - rlib_suffix.len())], CrateFlavor::Rlib) } else if f.starts_with(rmeta_prefix) && f.ends_with(rmeta_suffix) { (&f[rmeta_prefix.len()..(f.len() - rmeta_suffix.len())], CrateFlavor::Rmeta) - } else if f.starts_with(dylib_prefix) && f.ends_with(dylib_suffix) { + } else if f.starts_with(dylib_prefix) && f.ends_with(dylib_suffix.as_ref()) { (&f[dylib_prefix.len()..(f.len() - dylib_suffix.len())], CrateFlavor::Dylib) } else { - if f.starts_with(staticlib_prefix) && f.ends_with(staticlib_suffix) { + if f.starts_with(staticlib_prefix) && f.ends_with(staticlib_suffix.as_ref()) { self.crate_rejections.via_kind.push(CrateMismatch { path: spf.path.clone(), got: "static".to_string(), @@ -698,8 +698,8 @@ impl<'a> CrateLocator<'a> { }; if file.starts_with("lib") && (file.ends_with(".rlib") || file.ends_with(".rmeta")) - || file.starts_with(&self.target.dll_prefix) - && file.ends_with(&self.target.dll_suffix) + || file.starts_with(self.target.dll_prefix.as_ref()) + && file.ends_with(self.target.dll_suffix.as_ref()) { // Make sure there's at most one rlib and at most one dylib. // Note to take care and match against the non-canonicalized name: @@ -733,8 +733,8 @@ impl<'a> CrateLocator<'a> { crate_name: self.crate_name, root, triple: self.triple, - dll_prefix: self.target.dll_prefix.clone(), - dll_suffix: self.target.dll_suffix.clone(), + dll_prefix: self.target.dll_prefix.to_string(), + dll_suffix: self.target.dll_suffix.to_string(), crate_rejections: self.crate_rejections, }) } diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs index 0cbea3a07a8..9847fde3c49 100644 --- a/compiler/rustc_serialize/src/json.rs +++ b/compiler/rustc_serialize/src/json.rs @@ -170,6 +170,7 @@ use self::JsonEvent::*; use self::ParserError::*; use self::ParserState::*; +use std::borrow::Cow; use std::collections::{BTreeMap, HashMap}; use std::mem::swap; use std::num::FpCategory as Fp; @@ -2196,6 +2197,12 @@ impl ToJson for string::String { } } +impl<'a> ToJson for Cow<'a, str> { + fn to_json(&self) -> Json { + Json::String(self.to_string()) + } +} + macro_rules! tuple_impl { // use variables to indicate the arity of the tuple ($($tyvar:ident),* ) => { diff --git a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs index f01ff02da07..ef9e6bbea4d 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs @@ -2,13 +2,13 @@ use crate::spec::{FramePointer, LinkerFlavor, SanitizerSet, Target, TargetOption pub fn target() -> Target { let mut base = super::apple_base::opts("macos"); - base.cpu = "apple-a14".to_string(); + base.cpu = "apple-a14".into(); base.max_atomic_width = Some(128); // FIXME: The leak sanitizer currently fails the tests, see #88132. base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".to_string(), "arm64".to_string()]); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".into(), "arm64".into()]); base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); // Clang automatically chooses a more specific target based on @@ -17,12 +17,12 @@ pub fn target() -> Target { let llvm_target = super::apple_base::macos_llvm_target("arm64"); Target { - llvm_target, + llvm_target: llvm_target.into(), pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - mcount: "\u{1}mcount".to_string(), + mcount: "\u{1}mcount".into(), frame_pointer: FramePointer::NonLeaf, ..base }, diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios.rs index 6468419fce7..beb9042390b 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_ios.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_ios.rs @@ -10,12 +10,12 @@ pub fn target() -> Target { let llvm_target = super::apple_base::ios_llvm_target(arch); Target { - llvm_target, + llvm_target: llvm_target.into(), pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".to_string(), + features: "+neon,+fp-armv8,+apple-a7".into(), max_atomic_width: Some(128), forces_embed_bitcode: true, frame_pointer: FramePointer::NonLeaf, @@ -29,7 +29,7 @@ pub fn target() -> Target { -target-abi\0\ darwinpcs\0\ -Os\0" - .to_string(), + .into(), ..opts("ios", Arch::Arm64) }, } diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs index d16328f00f9..57634cbbfb1 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs @@ -3,12 +3,12 @@ use crate::spec::{FramePointer, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "arm64-apple-ios14.0-macabi".to_string(), + llvm_target: "arm64-apple-ios14.0-macabi".into(), pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a12".to_string(), + features: "+neon,+fp-armv8,+apple-a12".into(), max_atomic_width: Some(128), forces_embed_bitcode: true, frame_pointer: FramePointer::NonLeaf, @@ -20,7 +20,7 @@ pub fn target() -> Target { -emit-obj\0\ -disable-llvm-passes\0\ -Os\0" - .to_string(), + .into(), ..opts("ios", Arch::Arm64_macabi) }, } diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs index 07b3453218f..b4e135f66e9 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs @@ -12,12 +12,12 @@ pub fn target() -> Target { let llvm_target = super::apple_base::ios_sim_llvm_target(arch); Target { - llvm_target: llvm_target, + llvm_target: llvm_target.into(), pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".to_string(), + features: "+neon,+fp-armv8,+apple-a7".into(), max_atomic_width: Some(128), forces_embed_bitcode: true, frame_pointer: FramePointer::NonLeaf, @@ -31,7 +31,7 @@ pub fn target() -> Target { -target-abi\0\ darwinpcs\0\ -Os\0" - .to_string(), + .into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/aarch64_apple_tvos.rs b/compiler/rustc_target/src/spec/aarch64_apple_tvos.rs index b4bd72a082b..2e31d16dc76 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_tvos.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_tvos.rs @@ -3,12 +3,12 @@ use crate::spec::{FramePointer, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "arm64-apple-tvos".to_string(), + llvm_target: "arm64-apple-tvos".into(), pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".to_string(), + features: "+neon,+fp-armv8,+apple-a7".into(), max_atomic_width: Some(128), forces_embed_bitcode: true, frame_pointer: FramePointer::NonLeaf, diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs index a393858879b..9bce82a191e 100644 --- a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs @@ -3,14 +3,14 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64_be-unknown-linux-gnu".to_string(), + llvm_target: "aarch64_be-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - features: "+outline-atomics".to_string(), + features: "+outline-atomics".into(), max_atomic_width: Some(128), - mcount: "\u{1}_mcount".to_string(), + mcount: "\u{1}_mcount".into(), endian: Endian::Big, ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs index e75100f1435..c9ceb55ddad 100644 --- a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs +++ b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs @@ -6,14 +6,14 @@ pub fn target() -> Target { base.max_atomic_width = Some(128); Target { - llvm_target: "aarch64_be-unknown-linux-gnu_ilp32".to_string(), + llvm_target: "aarch64_be-unknown-linux-gnu_ilp32".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - abi: "ilp32".to_string(), - features: "+outline-atomics".to_string(), - mcount: "\u{1}_mcount".to_string(), + abi: "ilp32".into(), + features: "+outline-atomics".into(), + mcount: "\u{1}_mcount".into(), endian: Endian::Big, ..base }, diff --git a/compiler/rustc_target/src/spec/aarch64_fuchsia.rs b/compiler/rustc_target/src/spec/aarch64_fuchsia.rs index 05e0c65dd5c..4634433c4a9 100644 --- a/compiler/rustc_target/src/spec/aarch64_fuchsia.rs +++ b/compiler/rustc_target/src/spec/aarch64_fuchsia.rs @@ -2,10 +2,10 @@ use crate::spec::{SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-fuchsia".to_string(), + llvm_target: "aarch64-fuchsia".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI, diff --git a/compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs b/compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs index 61e3be617e9..6ea9ae2667e 100644 --- a/compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs +++ b/compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs @@ -3,13 +3,13 @@ use super::{RelocModel, Target, TargetOptions}; pub fn target() -> Target { let base = super::solid_base::opts("asp3"); Target { - llvm_target: "aarch64-unknown-none".to_string(), + llvm_target: "aarch64-unknown-none".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - linker: Some("aarch64-kmc-elf-gcc".to_owned()), - features: "+neon,+fp-armv8".to_string(), + linker: Some("aarch64-kmc-elf-gcc".into()), + features: "+neon,+fp-armv8".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/aarch64_linux_android.rs b/compiler/rustc_target/src/spec/aarch64_linux_android.rs index 87696b3664c..5e31859aaef 100644 --- a/compiler/rustc_target/src/spec/aarch64_linux_android.rs +++ b/compiler/rustc_target/src/spec/aarch64_linux_android.rs @@ -5,15 +5,15 @@ use crate::spec::{SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-linux-android".to_string(), + llvm_target: "aarch64-linux-android".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { max_atomic_width: Some(128), // As documented in https://developer.android.com/ndk/guides/cpu-features.html // the neon (ASIMD) and FP must exist on all android aarch64 targets. - features: "+neon,+fp-armv8".to_string(), + features: "+neon,+fp-armv8".into(), supported_sanitizers: SanitizerSet::CFI | SanitizerSet::HWADDRESS | SanitizerSet::MEMTAG diff --git a/compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs index a9a0977e702..856ec4fb0b4 100644 --- a/compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs @@ -3,13 +3,13 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::windows_msvc_base::opts(); base.max_atomic_width = Some(64); - base.features = "+neon,+fp-armv8".to_string(); + base.features = "+neon,+fp-armv8".into(); Target { - llvm_target: "aarch64-pc-windows-msvc".to_string(), + llvm_target: "aarch64-pc-windows-msvc".into(), pointer_width: 64, - data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs index 03ee7ba4875..2f39c4862cf 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs @@ -2,10 +2,10 @@ use crate::spec::{SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-unknown-freebsd".to_string(), + llvm_target: "aarch64-unknown-freebsd".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs b/compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs index f8e1e1b02f5..1d7269c8d73 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs @@ -3,13 +3,13 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::hermit_base::opts(); base.max_atomic_width = Some(128); - base.features = "+strict-align,+neon,+fp-armv8".to_string(); + base.features = "+strict-align,+neon,+fp-armv8".into(); Target { - llvm_target: "aarch64-unknown-hermit".to_string(), + llvm_target: "aarch64-unknown-hermit".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs index 974a5b84d1d..3006044d54a 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs @@ -2,13 +2,13 @@ use crate::spec::{SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-unknown-linux-gnu".to_string(), + llvm_target: "aarch64-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - features: "+outline-atomics".to_string(), - mcount: "\u{1}_mcount".to_string(), + features: "+outline-atomics".into(), + mcount: "\u{1}_mcount".into(), max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs index 1c931d5a705..63023df1d6c 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs @@ -2,15 +2,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-unknown-linux-gnu_ilp32".to_string(), + llvm_target: "aarch64-unknown-linux-gnu_ilp32".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - abi: "ilp32".to_string(), - features: "+outline-atomics".to_string(), + abi: "ilp32".into(), + features: "+outline-atomics".into(), max_atomic_width: Some(128), - mcount: "\u{1}_mcount".to_string(), + mcount: "\u{1}_mcount".into(), ..super::linux_gnu_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs index 6a16b4ce419..002d0dac2a6 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs @@ -5,10 +5,10 @@ pub fn target() -> Target { base.max_atomic_width = Some(128); Target { - llvm_target: "aarch64-unknown-linux-musl".to_string(), + llvm_target: "aarch64-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), - options: TargetOptions { mcount: "\u{1}_mcount".to_string(), ..base }, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { mcount: "\u{1}_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs index 4042028e2dc..703f7502295 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs @@ -2,12 +2,12 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-unknown-netbsd".to_string(), + llvm_target: "aarch64-unknown-netbsd".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { - mcount: "__mcount".to_string(), + mcount: "__mcount".into(), max_atomic_width: Some(128), ..super::netbsd_base::opts() }, diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_none.rs b/compiler/rustc_target/src/spec/aarch64_unknown_none.rs index 9d365279010..2c7834c225b 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_none.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_none.rs @@ -11,8 +11,8 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp pub fn target() -> Target { let opts = TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_owned()), - features: "+strict-align,+neon,+fp-armv8".to_string(), + linker: Some("rust-lld".into()), + features: "+strict-align,+neon,+fp-armv8".into(), executables: true, relocation_model: RelocModel::Static, disable_redzone: true, @@ -21,10 +21,10 @@ pub fn target() -> Target { ..Default::default() }; Target { - llvm_target: "aarch64-unknown-none".to_string(), + llvm_target: "aarch64-unknown-none".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: opts, } } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs index fa93ca80549..1b6525a7c69 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs @@ -10,10 +10,10 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp pub fn target() -> Target { let opts = TargetOptions { - abi: "softfloat".to_string(), + abi: "softfloat".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_owned()), - features: "+strict-align,-neon,-fp-armv8".to_string(), + linker: Some("rust-lld".into()), + features: "+strict-align,-neon,-fp-armv8".into(), executables: true, relocation_model: RelocModel::Static, disable_redzone: true, @@ -22,10 +22,10 @@ pub fn target() -> Target { ..Default::default() }; Target { - llvm_target: "aarch64-unknown-none".to_string(), + llvm_target: "aarch64-unknown-none".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: opts, } } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs index 193f9814210..3d99040f0d3 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs @@ -2,10 +2,10 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-unknown-openbsd".to_string(), + llvm_target: "aarch64-unknown-openbsd".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { max_atomic_width: Some(128), ..super::openbsd_base::opts() }, } } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_redox.rs b/compiler/rustc_target/src/spec/aarch64_unknown_redox.rs index b9c9325831d..6c9be4c8e93 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_redox.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_redox.rs @@ -5,10 +5,10 @@ pub fn target() -> Target { base.max_atomic_width = Some(128); Target { - llvm_target: "aarch64-unknown-redox".to_string(), + llvm_target: "aarch64-unknown-redox".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs b/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs index 20c528d25f3..965b254c289 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs @@ -9,7 +9,7 @@ pub fn target() -> Target { base.max_atomic_width = Some(64); - let pre_link_args_msvc = vec!["/machine:arm64".to_string()]; + let pre_link_args_msvc = vec!["/machine:arm64".into()]; base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap().extend(pre_link_args_msvc.clone()); base.pre_link_args @@ -18,10 +18,10 @@ pub fn target() -> Target { .extend(pre_link_args_msvc); Target { - llvm_target: "aarch64-unknown-windows".to_string(), + llvm_target: "aarch64-unknown-windows".into(), pointer_width: 64, - data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs index db4eb204e0b..54247fd93f2 100644 --- a/compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs @@ -5,10 +5,10 @@ pub fn target() -> Target { base.max_atomic_width = Some(64); Target { - llvm_target: "aarch64-pc-windows-msvc".to_string(), + llvm_target: "aarch64-pc-windows-msvc".into(), pointer_width: 64, - data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs index 66140060f8e..e118553dfd2 100644 --- a/compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs @@ -2,10 +2,10 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "aarch64-unknown-linux-gnu".to_string(), + llvm_target: "aarch64-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), options: TargetOptions { max_atomic_width: Some(128), ..super::vxworks_base::opts() }, } } diff --git a/compiler/rustc_target/src/spec/android_base.rs b/compiler/rustc_target/src/spec/android_base.rs index dc14d260e92..c2b9d696776 100644 --- a/compiler/rustc_target/src/spec/android_base.rs +++ b/compiler/rustc_target/src/spec/android_base.rs @@ -2,7 +2,7 @@ use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { let mut base = super::linux_base::opts(); - base.os = "android".to_string(); + base.os = "android".into(); base.dwarf_version = Some(2); base.position_independent_executables = true; base.has_thread_local = false; diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index a4488f695f2..748989b2a6f 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -1,8 +1,8 @@ -use std::env; +use std::{borrow::Cow, env}; use crate::spec::{FramePointer, LldFlavor, SplitDebuginfo, TargetOptions}; -pub fn opts(os: &str) -> TargetOptions { +pub fn opts(os: &'static str) -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 // either the linker will complain if it is used or the binary will end up // segfaulting at runtime when run on 10.6. Rust by default supports macOS @@ -19,20 +19,20 @@ pub fn opts(os: &str) -> TargetOptions { let has_thread_local = macos_deployment_target("x86_64") >= (10, 7); TargetOptions { - os: os.to_string(), - vendor: "apple".to_string(), + os: os.into(), + vendor: "apple".into(), // macOS has -dead_strip, which doesn't rely on function_sections function_sections: false, dynamic_linking: true, linker_is_gnu: false, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], is_like_osx: true, dwarf_version: Some(2), frame_pointer: FramePointer::Always, has_rpath: true, - dll_suffix: ".dylib".to_string(), - archive_format: "darwin".to_string(), + dll_suffix: ".dylib".into(), + archive_format: "darwin".into(), has_thread_local, abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, @@ -51,7 +51,7 @@ pub fn opts(os: &str) -> TargetOptions { // this environment variable too in recent versions. // // For some more info see the commentary on #47086 - link_env: vec![("ZERO_AR_DATE".to_string(), "1".to_string())], + link_env: vec![("ZERO_AR_DATE".into(), "1".into())], ..Default::default() } @@ -79,19 +79,19 @@ pub fn macos_llvm_target(arch: &str) -> String { format!("{}-apple-macosx{}.{}.0", arch, major, minor) } -pub fn macos_link_env_remove() -> Vec { +pub fn macos_link_env_remove() -> Vec> { let mut env_remove = Vec::with_capacity(2); // Remove the `SDKROOT` environment variable if it's clearly set for the wrong platform, which // may occur when we're linking a custom build script while targeting iOS for example. if let Ok(sdkroot) = env::var("SDKROOT") { if sdkroot.contains("iPhoneOS.platform") || sdkroot.contains("iPhoneSimulator.platform") { - env_remove.push("SDKROOT".to_string()) + env_remove.push("SDKROOT".into()) } } // Additionally, `IPHONEOS_DEPLOYMENT_TARGET` must not be set when using the Xcode linker at // "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld", // although this is apparently ignored when using the linker at "/usr/bin/ld". - env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".to_string()); + env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into()); env_remove } diff --git a/compiler/rustc_target/src/spec/apple_sdk_base.rs b/compiler/rustc_target/src/spec/apple_sdk_base.rs index 874e9b56aaa..3ab9dbe07a3 100644 --- a/compiler/rustc_target/src/spec/apple_sdk_base.rs +++ b/compiler/rustc_target/src/spec/apple_sdk_base.rs @@ -1,4 +1,5 @@ use crate::spec::TargetOptions; +use std::borrow::Cow; use Arch::*; #[allow(non_camel_case_types)] @@ -14,16 +15,15 @@ pub enum Arch { Arm64_sim, } -fn target_abi(arch: Arch) -> String { +fn target_abi(arch: Arch) -> &'static str { match arch { Armv7 | Armv7s | Arm64 | I386 | X86_64 => "", X86_64_macabi | Arm64_macabi => "macabi", Arm64_sim => "sim", } - .to_string() } -fn target_cpu(arch: Arch) -> String { +fn target_cpu(arch: Arch) -> &'static str { match arch { Armv7 => "cortex-a8", // iOS7 is supported on iPhone 4 and higher Armv7s => "cortex-a9", @@ -34,22 +34,21 @@ fn target_cpu(arch: Arch) -> String { Arm64_macabi => "apple-a12", Arm64_sim => "apple-a12", } - .to_string() } -fn link_env_remove(arch: Arch) -> Vec { +fn link_env_remove(arch: Arch) -> Vec> { match arch { Armv7 | Armv7s | Arm64 | I386 | X86_64 | Arm64_sim => { - vec!["MACOSX_DEPLOYMENT_TARGET".to_string()] + vec!["MACOSX_DEPLOYMENT_TARGET".into()] } - X86_64_macabi | Arm64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".to_string()], + X86_64_macabi | Arm64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".into()], } } -pub fn opts(os: &str, arch: Arch) -> TargetOptions { +pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { TargetOptions { - abi: target_abi(arch), - cpu: target_cpu(arch), + abi: target_abi(arch).into(), + cpu: target_cpu(arch).into(), dynamic_linking: false, executables: true, link_env_remove: link_env_remove(arch), diff --git a/compiler/rustc_target/src/spec/arm_linux_androideabi.rs b/compiler/rustc_target/src/spec/arm_linux_androideabi.rs index 933b43986c9..bbf1fa315ab 100644 --- a/compiler/rustc_target/src/spec/arm_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/arm_linux_androideabi.rs @@ -2,14 +2,14 @@ use crate::spec::{SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "arm-linux-androideabi".to_string(), + llvm_target: "arm-linux-androideabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), // https://developer.android.com/ndk/guides/abis.html#armeabi - features: "+strict-align,+v5te".to_string(), + features: "+strict-align,+v5te".into(), supported_sanitizers: SanitizerSet::ADDRESS, max_atomic_width: Some(32), ..super::android_base::opts() diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs index 442f56d4fb5..c0f1827ad3f 100644 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs @@ -2,15 +2,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "arm-unknown-linux-gnueabi".to_string(), + llvm_target: "arm-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+strict-align,+v6".to_string(), + abi: "eabi".into(), + features: "+strict-align,+v6".into(), max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), ..super::linux_gnu_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs index 2c12a71e29f..79b8958c22a 100644 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs @@ -2,15 +2,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "arm-unknown-linux-gnueabihf".to_string(), + llvm_target: "arm-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), - features: "+strict-align,+v6,+vfp2,-d32".to_string(), + abi: "eabihf".into(), + features: "+strict-align,+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), ..super::linux_gnu_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs index d187dfd9189..3ef441d6a60 100644 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs +++ b/compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs @@ -5,17 +5,17 @@ pub fn target() -> Target { // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it // to determine the calling convention and float ABI, and it doesn't // support the "musleabi" value. - llvm_target: "arm-unknown-linux-gnueabi".to_string(), + llvm_target: "arm-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), // Most of these settings are copied from the arm_unknown_linux_gnueabi // target. - features: "+strict-align,+v6".to_string(), + features: "+strict-align,+v6".into(), max_atomic_width: Some(64), - mcount: "\u{1}mcount".to_string(), + mcount: "\u{1}mcount".into(), ..super::linux_musl_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs index 3d72734f5fa..eb6660d4c28 100644 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs @@ -5,17 +5,17 @@ pub fn target() -> Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and it // doesn't support the "musleabihf" value. - llvm_target: "arm-unknown-linux-gnueabihf".to_string(), + llvm_target: "arm-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // Most of these settings are copied from the arm_unknown_linux_gnueabihf // target. - features: "+strict-align,+v6,+vfp2,-d32".to_string(), + features: "+strict-align,+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), - mcount: "\u{1}mcount".to_string(), + mcount: "\u{1}mcount".into(), ..super::linux_musl_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs b/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs index ed4779c0c02..0cb18f17310 100644 --- a/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs +++ b/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs @@ -6,16 +6,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armebv7r-unknown-none-eabi".to_string(), + llvm_target: "armebv7r-unknown-none-eabi".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), endian: Endian::Big, linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), executables: true, - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), relocation_model: RelocModel::Static, panic_strategy: PanicStrategy::Abort, max_atomic_width: Some(32), diff --git a/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs index b60e2895d77..a5b7c12cc7b 100644 --- a/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs @@ -6,19 +6,19 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armebv7r-unknown-none-eabihf".to_string(), + llvm_target: "armebv7r-unknown-none-eabihf".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), endian: Endian::Big, linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), executables: true, - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), relocation_model: RelocModel::Static, panic_strategy: PanicStrategy::Abort, - features: "+vfp3,-d32,-fp16".to_string(), + features: "+vfp3,-d32,-fp16".into(), max_atomic_width: Some(32), emit_debug_gdb_scripts: false, // GCC and Clang default to 8 for arm-none here diff --git a/compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs index f1b193a384f..1de63a920c8 100644 --- a/compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs @@ -2,16 +2,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv4t-unknown-linux-gnueabi".to_string(), + llvm_target: "armv4t-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+soft-float,+strict-align".to_string(), + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), // Atomic operations provided by compiler-builtins max_atomic_width: Some(32), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), has_thumb_interworking: true, ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs index a6c4f2304c2..b940563102b 100644 --- a/compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs @@ -2,16 +2,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv5te-unknown-linux-gnueabi".to_string(), + llvm_target: "armv5te-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+soft-float,+strict-align".to_string(), + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), // Atomic operations provided by compiler-builtins max_atomic_width: Some(32), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), has_thumb_interworking: true, ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs index de2a350e231..2530971b502 100644 --- a/compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs +++ b/compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs @@ -6,16 +6,16 @@ pub fn target() -> Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. - llvm_target: "armv5te-unknown-linux-gnueabi".to_string(), + llvm_target: "armv5te-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+soft-float,+strict-align".to_string(), + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), // Atomic operations provided by compiler-builtins max_atomic_width: Some(32), - mcount: "\u{1}mcount".to_string(), + mcount: "\u{1}mcount".into(), has_thumb_interworking: true, ..super::linux_musl_base::opts() }, diff --git a/compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs index 91b4bd27caa..a51be10a3d8 100644 --- a/compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs +++ b/compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs @@ -2,16 +2,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv5te-unknown-linux-uclibcgnueabi".to_string(), + llvm_target: "armv5te-unknown-linux-uclibcgnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+soft-float,+strict-align".to_string(), + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), // Atomic operations provided by compiler-builtins max_atomic_width: Some(32), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), has_thumb_interworking: true, ..super::linux_uclibc_base::opts() }, diff --git a/compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs b/compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs index ee2f8f6238b..b7cfccc8b3d 100644 --- a/compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs @@ -2,17 +2,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv6-unknown-freebsd-gnueabihf".to_string(), + llvm_target: "armv6-unknown-freebsd-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".to_string(), - features: "+v6,+vfp2,-d32".to_string(), + env: "gnueabihf".into(), + features: "+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), ..super::freebsd_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs index b046819d4d7..6e26f686fcb 100644 --- a/compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs @@ -2,17 +2,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv6-unknown-netbsdelf-eabihf".to_string(), + llvm_target: "armv6-unknown-netbsdelf-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".to_string(), - features: "+v6,+vfp2,-d32".to_string(), + env: "eabihf".into(), + features: "+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), - mcount: "__mcount".to_string(), + mcount: "__mcount".into(), ..super::netbsd_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs index 84105fbad47..93897dd4938 100644 --- a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs +++ b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs @@ -9,33 +9,33 @@ pub fn target() -> Target { pre_link_args.insert( LinkerFlavor::Gcc, vec![ - "-specs=3dsx.specs".to_string(), - "-mtune=mpcore".to_string(), - "-mfloat-abi=hard".to_string(), - "-mtp=soft".to_string(), + "-specs=3dsx.specs".into(), + "-mtune=mpcore".into(), + "-mfloat-abi=hard".into(), + "-mtp=soft".into(), ], ); Target { - llvm_target: "armv6k-none-eabihf".to_string(), + llvm_target: "armv6k-none-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - os: "horizon".to_string(), - env: "newlib".to_string(), - vendor: "nintendo".to_string(), - abi: "eabihf".to_string(), + os: "horizon".into(), + env: "newlib".into(), + vendor: "nintendo".into(), + abi: "eabihf".into(), linker_flavor: LinkerFlavor::Gcc, - cpu: "mpcore".to_string(), + cpu: "mpcore".into(), executables: true, - families: vec!["unix".to_string()], - linker: Some("arm-none-eabi-gcc".to_string()), + families: vec!["unix".into()], + linker: Some("arm-none-eabi-gcc".into()), relocation_model: RelocModel::Static, - features: "+vfp2".to_string(), + features: "+vfp2".into(), pre_link_args, - exe_suffix: ".elf".to_string(), + exe_suffix: ".elf".into(), no_default_libraries: false, has_thread_local: true, ..Default::default() diff --git a/compiler/rustc_target/src/spec/armv7_apple_ios.rs b/compiler/rustc_target/src/spec/armv7_apple_ios.rs index 1f90c78f14a..57fd74a36b6 100644 --- a/compiler/rustc_target/src/spec/armv7_apple_ios.rs +++ b/compiler/rustc_target/src/spec/armv7_apple_ios.rs @@ -2,13 +2,15 @@ use super::apple_sdk_base::{opts, Arch}; use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { + let llvm_target = super::apple_base::ios_llvm_target("armv7"); + Target { - llvm_target: super::apple_base::ios_llvm_target("armv7"), + llvm_target: llvm_target.into(), pointer_width: 32, - data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".into(), + arch: "arm".into(), options: TargetOptions { - features: "+v7,+vfp3,+neon".to_string(), + features: "+v7,+vfp3,+neon".into(), max_atomic_width: Some(64), ..opts("ios", Arch::Armv7) }, diff --git a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs b/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs index adf831c12eb..2afd93fcad8 100644 --- a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs @@ -10,15 +10,15 @@ use crate::spec::{LinkerFlavor, SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::android_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-march=armv7-a".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-march=armv7-a".into()); Target { - llvm_target: "armv7-none-linux-android".to_string(), + llvm_target: "armv7-none-linux-android".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".to_string(), + abi: "eabi".into(), + features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".into(), supported_sanitizers: SanitizerSet::ADDRESS, max_atomic_width: Some(64), ..base diff --git a/compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs b/compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs index fbfb1c27681..bc37b62de8e 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs @@ -2,17 +2,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7-unknown-freebsd-gnueabihf".to_string(), + llvm_target: "armv7-unknown-freebsd-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".to_string(), - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), + env: "gnueabihf".into(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), ..super::freebsd_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs index 0a3b8033dd1..903042d7e7a 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs @@ -5,15 +5,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7-unknown-linux-gnueabi".to_string(), + llvm_target: "armv7-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+v7,+thumb2,+soft-float,-neon".to_string(), + abi: "eabi".into(), + features: "+v7,+thumb2,+soft-float,-neon".into(), max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), ..super::linux_gnu_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs index 662b81cae3e..e39ea49a003 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs @@ -5,16 +5,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), + llvm_target: "armv7-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".to_string(), + mcount: "\u{1}__gnu_mcount_nc".into(), ..super::linux_gnu_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs index c0fd1de17cf..7dae8577396 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs @@ -10,16 +10,16 @@ pub fn target() -> Target { // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it // to determine the calling convention and float ABI, and it doesn't // support the "musleabi" value. - llvm_target: "armv7-unknown-linux-gnueabi".to_string(), + llvm_target: "armv7-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+v7,+thumb2,+soft-float,-neon".to_string(), + abi: "eabi".into(), + features: "+v7,+thumb2,+soft-float,-neon".into(), max_atomic_width: Some(64), - mcount: "\u{1}mcount".to_string(), + mcount: "\u{1}mcount".into(), ..super::linux_musl_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs index 67ff7999dea..ba83964bf58 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs @@ -7,18 +7,18 @@ pub fn target() -> Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. - llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), + llvm_target: "armv7-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), // Most of these settings are copied from the armv7_unknown_linux_gnueabihf // target. options: TargetOptions { - abi: "eabihf".to_string(), - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), + abi: "eabihf".into(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), - mcount: "\u{1}mcount".to_string(), + mcount: "\u{1}mcount".into(), ..super::linux_musl_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs index 7faa8ed7a80..171f67070d5 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs @@ -6,17 +6,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let base = super::linux_uclibc_base::opts(); Target { - llvm_target: "armv7-unknown-linux-gnueabi".to_string(), + llvm_target: "armv7-unknown-linux-gnueabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - features: "+v7,+thumb2,+soft-float,-neon".to_string(), - cpu: "generic".to_string(), + features: "+v7,+thumb2,+soft-float,-neon".into(), + cpu: "generic".into(), max_atomic_width: Some(64), - mcount: "_mcount".to_string(), - abi: "eabi".to_string(), + mcount: "_mcount".into(), + abi: "eabi".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs index d230f77bde2..d3e95a6573d 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs @@ -6,18 +6,18 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let base = super::linux_uclibc_base::opts(); Target { - llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), + llvm_target: "armv7-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), - cpu: "generic".to_string(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + cpu: "generic".into(), max_atomic_width: Some(64), - mcount: "_mcount".to_string(), - abi: "eabihf".to_string(), + mcount: "_mcount".into(), + abi: "eabihf".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs index 60a552b018d..c89ae248398 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs @@ -2,17 +2,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7-unknown-netbsdelf-eabihf".to_string(), + llvm_target: "armv7-unknown-netbsdelf-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".to_string(), - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), + env: "eabihf".into(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), - mcount: "__mcount".to_string(), + mcount: "__mcount".into(), ..super::netbsd_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs b/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs index 27d404b101f..c1ab90172e2 100644 --- a/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs @@ -2,14 +2,14 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), + llvm_target: "armv7-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), ..super::vxworks_base::opts() }, diff --git a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs b/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs index 344c48022b2..b49dc650bd0 100644 --- a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs +++ b/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs @@ -3,13 +3,13 @@ use super::{RelocModel, Target, TargetOptions}; pub fn target() -> Target { let base = super::solid_base::opts("asp3"); Target { - llvm_target: "armv7a-none-eabi".to_string(), + llvm_target: "armv7a-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - linker: Some("arm-kmc-eabi-gcc".to_owned()), - features: "+v7,+soft-float,+thumb2,-neon".to_string(), + linker: Some("arm-kmc-eabi-gcc".into()), + features: "+v7,+soft-float,+thumb2,-neon".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(64), diff --git a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs b/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs index 375502478fe..7d30238e8ab 100644 --- a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs @@ -3,13 +3,13 @@ use super::{RelocModel, Target, TargetOptions}; pub fn target() -> Target { let base = super::solid_base::opts("asp3"); Target { - llvm_target: "armv7a-none-eabihf".to_string(), + llvm_target: "armv7a-none-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - linker: Some("arm-kmc-eabi-gcc".to_owned()), - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), + linker: Some("arm-kmc-eabi-gcc".into()), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(64), diff --git a/compiler/rustc_target/src/spec/armv7a_none_eabi.rs b/compiler/rustc_target/src/spec/armv7a_none_eabi.rs index 88040f49d9e..ff649434312 100644 --- a/compiler/rustc_target/src/spec/armv7a_none_eabi.rs +++ b/compiler/rustc_target/src/spec/armv7a_none_eabi.rs @@ -18,10 +18,10 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp pub fn target() -> Target { let opts = TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_owned()), - features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(), + linker: Some("rust-lld".into()), + features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(), executables: true, relocation_model: RelocModel::Static, disable_redzone: true, @@ -32,10 +32,10 @@ pub fn target() -> Target { ..Default::default() }; Target { - llvm_target: "armv7a-none-eabi".to_string(), + llvm_target: "armv7a-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: opts, } } diff --git a/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs b/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs index af324843ced..c0321d0bef4 100644 --- a/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs @@ -9,10 +9,10 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp pub fn target() -> Target { let opts = TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_owned()), - features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".to_string(), + linker: Some("rust-lld".into()), + features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(), executables: true, relocation_model: RelocModel::Static, disable_redzone: true, @@ -24,10 +24,10 @@ pub fn target() -> Target { ..Default::default() }; Target { - llvm_target: "armv7a-none-eabihf".to_string(), + llvm_target: "armv7a-none-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: opts, } } diff --git a/compiler/rustc_target/src/spec/armv7r_none_eabi.rs b/compiler/rustc_target/src/spec/armv7r_none_eabi.rs index c0e970983e7..2c3f79cc58b 100644 --- a/compiler/rustc_target/src/spec/armv7r_none_eabi.rs +++ b/compiler/rustc_target/src/spec/armv7r_none_eabi.rs @@ -5,16 +5,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7r-unknown-none-eabi".to_string(), + llvm_target: "armv7r-unknown-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), executables: true, - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), relocation_model: RelocModel::Static, panic_strategy: PanicStrategy::Abort, max_atomic_width: Some(32), diff --git a/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs index b126887b27b..5c82e768483 100644 --- a/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs @@ -5,19 +5,19 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7r-unknown-none-eabihf".to_string(), + llvm_target: "armv7r-unknown-none-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), executables: true, - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), relocation_model: RelocModel::Static, panic_strategy: PanicStrategy::Abort, - features: "+vfp3,-d32,-fp16".to_string(), + features: "+vfp3,-d32,-fp16".into(), max_atomic_width: Some(32), emit_debug_gdb_scripts: false, // GCC and Clang default to 8 for arm-none here diff --git a/compiler/rustc_target/src/spec/armv7s_apple_ios.rs b/compiler/rustc_target/src/spec/armv7s_apple_ios.rs index 2a48e7b6214..cc17265b2b8 100644 --- a/compiler/rustc_target/src/spec/armv7s_apple_ios.rs +++ b/compiler/rustc_target/src/spec/armv7s_apple_ios.rs @@ -3,12 +3,12 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7s-apple-ios".to_string(), + llvm_target: "armv7s-apple-ios".into(), pointer_width: 32, - data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".into(), + arch: "arm".into(), options: TargetOptions { - features: "+v7,+vfp4,+neon".to_string(), + features: "+v7,+vfp4,+neon".into(), max_atomic_width: Some(64), ..opts("ios", Arch::Armv7s) }, diff --git a/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs b/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs index b1adefe1a51..a90c7b7bc6f 100644 --- a/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs @@ -6,6 +6,6 @@ pub fn target() -> Target { .post_link_args .entry(LinkerFlavor::Em) .or_default() - .extend(vec!["-s".to_string(), "WASM=0".to_string()]); + .extend(vec!["-s".into(), "WASM=0".into()]); target } diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs index a6c1b344d70..9d4ec2edc51 100644 --- a/compiler/rustc_target/src/spec/avr_gnu_base.rs +++ b/compiler/rustc_target/src/spec/avr_gnu_base.rs @@ -3,24 +3,24 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; /// A base target for AVR devices using the GNU toolchain. /// /// Requires GNU avr-gcc and avr-binutils on the host system. -pub fn target(target_cpu: String) -> Target { +pub fn target(target_cpu: &'static str) -> Target { Target { - arch: "avr".to_string(), - data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".to_string(), - llvm_target: "avr-unknown-unknown".to_string(), + arch: "avr".into(), + data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(), + llvm_target: "avr-unknown-unknown".into(), pointer_width: 16, options: TargetOptions { - c_int_width: "16".to_string(), - cpu: target_cpu.clone(), - exe_suffix: ".elf".to_string(), + c_int_width: "16".into(), + cpu: target_cpu.into(), + exe_suffix: ".elf".into(), - linker: Some("avr-gcc".to_owned()), + linker: Some("avr-gcc".into()), executables: true, eh_frame_header: false, pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])] .into_iter() .collect(), - late_link_args: [(LinkerFlavor::Gcc, vec!["-lgcc".to_owned()])].into_iter().collect(), + late_link_args: [(LinkerFlavor::Gcc, vec!["-lgcc".into()])].into_iter().collect(), max_atomic_width: Some(0), atomic_cas: false, ..TargetOptions::default() diff --git a/compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs b/compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs index 7e63ae9c5aa..6871ca0f789 100644 --- a/compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs +++ b/compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs @@ -1,5 +1,5 @@ use crate::spec::Target; pub fn target() -> Target { - super::avr_gnu_base::target("atmega328".to_owned()) + super::avr_gnu_base::target("atmega328") } diff --git a/compiler/rustc_target/src/spec/bpfeb_unknown_none.rs b/compiler/rustc_target/src/spec/bpfeb_unknown_none.rs index a45da82eb40..174ddfa50bf 100644 --- a/compiler/rustc_target/src/spec/bpfeb_unknown_none.rs +++ b/compiler/rustc_target/src/spec/bpfeb_unknown_none.rs @@ -3,10 +3,10 @@ use crate::{abi::Endian, spec::bpf_base}; pub fn target() -> Target { Target { - llvm_target: "bpfeb".to_string(), - data_layout: "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128".to_string(), + llvm_target: "bpfeb".into(), + data_layout: "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), pointer_width: 64, - arch: "bpf".to_string(), + arch: "bpf".into(), options: bpf_base::opts(Endian::Big), } } diff --git a/compiler/rustc_target/src/spec/bpfel_unknown_none.rs b/compiler/rustc_target/src/spec/bpfel_unknown_none.rs index 6c9afdf35ae..7625e7b0e48 100644 --- a/compiler/rustc_target/src/spec/bpfel_unknown_none.rs +++ b/compiler/rustc_target/src/spec/bpfel_unknown_none.rs @@ -3,10 +3,10 @@ use crate::{abi::Endian, spec::bpf_base}; pub fn target() -> Target { Target { - llvm_target: "bpfel".to_string(), - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".to_string(), + llvm_target: "bpfel".into(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), pointer_width: 64, - arch: "bpf".to_string(), + arch: "bpf".into(), options: bpf_base::opts(Endian::Little), } } diff --git a/compiler/rustc_target/src/spec/crt_objects.rs b/compiler/rustc_target/src/spec/crt_objects.rs index 2fc9ab29f92..51f392a64b1 100644 --- a/compiler/rustc_target/src/spec/crt_objects.rs +++ b/compiler/rustc_target/src/spec/crt_objects.rs @@ -42,16 +42,17 @@ use crate::spec::LinkOutputKind; use rustc_serialize::json::{Json, ToJson}; +use std::borrow::Cow; use std::collections::BTreeMap; use std::str::FromStr; -pub type CrtObjects = BTreeMap>; +pub type CrtObjects = BTreeMap>>; -pub(super) fn new(obj_table: &[(LinkOutputKind, &[&str])]) -> CrtObjects { - obj_table.iter().map(|(z, k)| (*z, k.iter().map(|b| b.to_string()).collect())).collect() +pub(super) fn new(obj_table: &[(LinkOutputKind, &[&'static str])]) -> CrtObjects { + obj_table.iter().map(|(z, k)| (*z, k.iter().map(|b| (*b).into()).collect())).collect() } -pub(super) fn all(obj: &str) -> CrtObjects { +pub(super) fn all(obj: &'static str) -> CrtObjects { new(&[ (LinkOutputKind::DynamicNoPicExe, &[obj]), (LinkOutputKind::DynamicPicExe, &[obj]), diff --git a/compiler/rustc_target/src/spec/dragonfly_base.rs b/compiler/rustc_target/src/spec/dragonfly_base.rs index e13a640d4d2..03e4b953184 100644 --- a/compiler/rustc_target/src/spec/dragonfly_base.rs +++ b/compiler/rustc_target/src/spec/dragonfly_base.rs @@ -2,10 +2,10 @@ use crate::spec::{RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { - os: "dragonfly".to_string(), + os: "dragonfly".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/freebsd_base.rs b/compiler/rustc_target/src/spec/freebsd_base.rs index f2ec6aae9f2..0153b4dd80f 100644 --- a/compiler/rustc_target/src/spec/freebsd_base.rs +++ b/compiler/rustc_target/src/spec/freebsd_base.rs @@ -2,10 +2,10 @@ use crate::spec::{RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { - os: "freebsd".to_string(), + os: "freebsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index 4a7686ae1a1..e802cdcf489 100644 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ b/compiler/rustc_target/src/spec/fuchsia_base.rs @@ -5,27 +5,27 @@ pub fn opts() -> TargetOptions { pre_link_args.insert( LinkerFlavor::Lld(LldFlavor::Ld), vec![ - "--build-id".to_string(), - "--hash-style=gnu".to_string(), - "-z".to_string(), - "max-page-size=4096".to_string(), - "-z".to_string(), - "now".to_string(), - "-z".to_string(), - "rodynamic".to_string(), - "-z".to_string(), - "separate-loadable-segments".to_string(), - "--pack-dyn-relocs=relr".to_string(), + "--build-id".into(), + "--hash-style=gnu".into(), + "-z".into(), + "max-page-size=4096".into(), + "-z".into(), + "now".into(), + "-z".into(), + "rodynamic".into(), + "-z".into(), + "separate-loadable-segments".into(), + "--pack-dyn-relocs=relr".into(), ], ); TargetOptions { - os: "fuchsia".to_string(), + os: "fuchsia".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], is_like_fuchsia: true, pre_link_args, pre_link_objects: crt_objects::new(&[ diff --git a/compiler/rustc_target/src/spec/haiku_base.rs b/compiler/rustc_target/src/spec/haiku_base.rs index 2b95523d6f7..3585604a640 100644 --- a/compiler/rustc_target/src/spec/haiku_base.rs +++ b/compiler/rustc_target/src/spec/haiku_base.rs @@ -2,10 +2,10 @@ use crate::spec::{RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { - os: "haiku".to_string(), + os: "haiku".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], relro_level: RelroLevel::Full, ..Default::default() } diff --git a/compiler/rustc_target/src/spec/hermit_base.rs b/compiler/rustc_target/src/spec/hermit_base.rs index b0b1d80ab37..7cbd42417e6 100644 --- a/compiler/rustc_target/src/spec/hermit_base.rs +++ b/compiler/rustc_target/src/spec/hermit_base.rs @@ -4,13 +4,13 @@ pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); pre_link_args.insert( LinkerFlavor::Lld(LldFlavor::Ld), - vec!["--build-id".to_string(), "--hash-style=gnu".to_string(), "--Bstatic".to_string()], + vec!["--build-id".into(), "--hash-style=gnu".into(), "--Bstatic".into()], ); TargetOptions { - os: "hermit".to_string(), + os: "hermit".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), executables: true, has_thread_local: true, pre_link_args, diff --git a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs index 27d306c41b7..80cf09517cc 100644 --- a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs @@ -2,10 +2,10 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "hexagonv60".to_string(); + base.cpu = "hexagonv60".into(); base.max_atomic_width = Some(32); // FIXME: HVX length defaults are per-CPU - base.features = "-small-data,+hvx-length128b".to_string(); + base.features = "-small-data,+hvx-length128b".into(); base.crt_static_default = false; base.has_rpath = true; @@ -16,7 +16,7 @@ pub fn target() -> Target { base.c_enum_min_bits = 8; Target { - llvm_target: "hexagon-unknown-linux-musl".to_string(), + llvm_target: "hexagon-unknown-linux-musl".into(), pointer_width: 32, data_layout: concat!( "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32", @@ -24,8 +24,8 @@ pub fn target() -> Target { ":32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048", ":2048:2048" ) - .to_string(), - arch: "hexagon".to_string(), + .into(), + arch: "hexagon".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i386_apple_ios.rs b/compiler/rustc_target/src/spec/i386_apple_ios.rs index 4419dfe92f4..8b6266c5800 100644 --- a/compiler/rustc_target/src/spec/i386_apple_ios.rs +++ b/compiler/rustc_target/src/spec/i386_apple_ios.rs @@ -3,13 +3,15 @@ use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { let base = opts("ios", Arch::I386); + let llvm_target = super::apple_base::ios_sim_llvm_target("i386"); + Target { - llvm_target: super::apple_base::ios_sim_llvm_target("i386"), + llvm_target: llvm_target.into(), pointer_width: 32, data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:128-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: TargetOptions { max_atomic_width: Some(64), // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved diff --git a/compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs index f329b2d2c88..801a8893399 100644 --- a/compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs @@ -2,7 +2,7 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::i686_unknown_linux_gnu::target(); - base.cpu = "i386".to_string(); - base.llvm_target = "i386-unknown-linux-gnu".to_string(); + base.cpu = "i386".into(); + base.llvm_target = "i386-unknown-linux-gnu".into(); base } diff --git a/compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs index 5d96a558cb7..a11fbecc3c3 100644 --- a/compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs @@ -2,7 +2,7 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::i686_unknown_linux_gnu::target(); - base.cpu = "i486".to_string(); - base.llvm_target = "i486-unknown-linux-gnu".to_string(); + base.cpu = "i486".into(); + base.llvm_target = "i486-unknown-linux-gnu".into(); base } diff --git a/compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs index 4a7779a6df0..befb0f89f3b 100644 --- a/compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs @@ -2,7 +2,7 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::i686_pc_windows_msvc::target(); - base.cpu = "pentium".to_string(); - base.llvm_target = "i586-pc-windows-msvc".to_string(); + base.cpu = "pentium".into(); + base.llvm_target = "i586-pc-windows-msvc".into(); base } diff --git a/compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs index 7c92dda8a9d..b699a7af177 100644 --- a/compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs @@ -2,7 +2,7 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::i686_unknown_linux_gnu::target(); - base.cpu = "pentium".to_string(); - base.llvm_target = "i586-unknown-linux-gnu".to_string(); + base.cpu = "pentium".into(); + base.llvm_target = "i586-unknown-linux-gnu".into(); base } diff --git a/compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs index 1fea02bbee8..55a26eb004a 100644 --- a/compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs @@ -2,7 +2,7 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::i686_unknown_linux_musl::target(); - base.cpu = "pentium".to_string(); - base.llvm_target = "i586-unknown-linux-musl".to_string(); + base.cpu = "pentium".into(); + base.llvm_target = "i586-unknown-linux-musl".into(); base } diff --git a/compiler/rustc_target/src/spec/i686_apple_darwin.rs b/compiler/rustc_target/src/spec/i686_apple_darwin.rs index f2635f0656d..a083a83e377 100644 --- a/compiler/rustc_target/src/spec/i686_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/i686_apple_darwin.rs @@ -2,9 +2,9 @@ use crate::spec::{FramePointer, LinkerFlavor, StackProbeType, Target, TargetOpti pub fn target() -> Target { let mut base = super::apple_base::opts("macos"); - base.cpu = "yonah".to_string(); + base.cpu = "yonah".into(); base.max_atomic_width = Some(64); - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".to_string()]); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".into()]); base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; @@ -17,12 +17,12 @@ pub fn target() -> Target { let llvm_target = super::apple_base::macos_llvm_target(&arch); Target { - llvm_target, + llvm_target: llvm_target.into(), pointer_width: 32, data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:128-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), - options: TargetOptions { mcount: "\u{1}mcount".to_string(), ..base }, + .into(), + arch: "x86".into(), + options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/i686_linux_android.rs b/compiler/rustc_target/src/spec/i686_linux_android.rs index e9ddaa37c26..bdaf5c99069 100644 --- a/compiler/rustc_target/src/spec/i686_linux_android.rs +++ b/compiler/rustc_target/src/spec/i686_linux_android.rs @@ -9,18 +9,18 @@ pub fn target() -> Target { base.max_atomic_width = Some(64); // https://developer.android.com/ndk/guides/abis.html#x86 - base.cpu = "pentiumpro".to_string(); - base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".to_string(); + base.cpu = "pentiumpro".into(); + base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into(); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "i686-linux-android".to_string(), + llvm_target: "i686-linux-android".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, } } diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs index 92c3a1554ac..554b0f34499 100644 --- a/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs @@ -2,27 +2,26 @@ use crate::spec::{FramePointer, LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut base = super::windows_gnu_base::opts(); - base.cpu = "pentium4".to_string(); - base.pre_link_args - .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pe".to_string()]); + base.cpu = "pentium4".into(); + base.pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".into(), "i386pe".into()]); base.max_atomic_width = Some(64); base.frame_pointer = FramePointer::Always; // Required for backtraces - base.linker = Some("i686-w64-mingw32-gcc".to_string()); + base.linker = Some("i686-w64-mingw32-gcc".into()); // Mark all dynamic libraries and executables as compatible with the larger 4GiB address // space available to x86 Windows binaries on x86_64. base.pre_link_args .entry(LinkerFlavor::Gcc) .or_default() - .push("-Wl,--large-address-aware".to_string()); + .push("-Wl,--large-address-aware".into()); Target { - llvm_target: "i686-pc-windows-gnu".to_string(), + llvm_target: "i686-pc-windows-gnu".into(), pointer_width: 32, data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-f80:32-n8:16:32-a:0:32-S32" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs index 5b30dc1d3da..fb0cb6a6943 100644 --- a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs @@ -2,17 +2,17 @@ use crate::spec::{LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut base = super::windows_msvc_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); let pre_link_args_msvc = vec![ // Mark all dynamic libraries and executables as compatible with the larger 4GiB address // space available to x86 Windows binaries on x86_64. - "/LARGEADDRESSAWARE".to_string(), + "/LARGEADDRESSAWARE".into(), // Ensure the linker will only produce an image if it can also produce a table of // the image's safe exception handlers. // https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers - "/SAFESEH".to_string(), + "/SAFESEH".into(), ]; base.pre_link_args.entry(LinkerFlavor::Msvc).or_default().extend(pre_link_args_msvc.clone()); base.pre_link_args @@ -23,12 +23,12 @@ pub fn target() -> Target { base.has_thread_local = false; Target { - llvm_target: "i686-pc-windows-msvc".to_string(), + llvm_target: "i686-pc-windows-msvc".into(), pointer_width: 32, data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-f80:128-n8:16:32-a:0:32-S32" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs b/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs index d8e37e72371..9f0cb04c65d 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs @@ -2,21 +2,21 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::freebsd_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); let pre_link_args = base.pre_link_args.entry(LinkerFlavor::Gcc).or_default(); - pre_link_args.push("-m32".to_string()); - pre_link_args.push("-Wl,-znotext".to_string()); + pre_link_args.push("-m32".into()); + pre_link_args.push("-Wl,-znotext".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "i686-unknown-freebsd".to_string(), + llvm_target: "i686-unknown-freebsd".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_unknown_haiku.rs b/compiler/rustc_target/src/spec/i686_unknown_haiku.rs index e4c01db5439..d1af163f1cf 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_haiku.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_haiku.rs @@ -2,19 +2,19 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::haiku_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".to_string()]); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".into()]); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "i686-unknown-haiku".to_string(), + llvm_target: "i686-unknown-haiku".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs index 165505ee731..0998c618f31 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs @@ -2,19 +2,19 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "i686-unknown-linux-gnu".to_string(), + llvm_target: "i686-unknown-linux-gnu".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs index d95cb6a82d5..a697f292da0 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs @@ -2,10 +2,10 @@ use crate::spec::{FramePointer, LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-Wl,-melf_i386".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-Wl,-melf_i386".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; @@ -24,12 +24,12 @@ pub fn target() -> Target { base.frame_pointer = FramePointer::Always; Target { - llvm_target: "i686-unknown-linux-musl".to_string(), + llvm_target: "i686-unknown-linux-musl".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs b/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs index 989e3fb1adf..2807d328205 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs @@ -2,19 +2,19 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::netbsd_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "i686-unknown-netbsdelf".to_string(), + llvm_target: "i686-unknown-netbsdelf".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), - options: TargetOptions { mcount: "__mcount".to_string(), ..base }, + .into(), + arch: "x86".into(), + options: TargetOptions { mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs b/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs index 7ff79961375..78462eb63b8 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs @@ -2,20 +2,20 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::openbsd_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-fuse-ld=lld".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-fuse-ld=lld".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "i686-unknown-openbsd".to_string(), + llvm_target: "i686-unknown-openbsd".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_unknown_uefi.rs b/compiler/rustc_target/src/spec/i686_unknown_uefi.rs index cc3c31538a4..a2e42c5e61d 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_uefi.rs @@ -9,7 +9,7 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::uefi_msvc_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); // We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to @@ -21,7 +21,7 @@ pub fn target() -> Target { // far. // If you initialize FP units yourself, you can override these flags with custom linker // arguments, thus giving you access to full MMX/SSE acceleration. - base.features = "-mmx,-sse,+soft-float".to_string(); + base.features = "-mmx,-sse,+soft-float".into(); // Use -GNU here, because of the reason below: // Background and Problem: @@ -77,12 +77,12 @@ pub fn target() -> Target { // compiler-builtins. After compiler-builtins implements all required intrinsics, we may // remove -gnu and use the default one. Target { - llvm_target: "i686-unknown-windows-gnu".to_string(), + llvm_target: "i686-unknown-windows-gnu".into(), pointer_width: 32, data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-f80:32-n8:16:32-a:0:32-S32" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } diff --git a/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs index 27a0ac585e3..75f7a2209c8 100644 --- a/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs @@ -2,9 +2,8 @@ use crate::spec::{FramePointer, LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut base = super::windows_uwp_gnu_base::opts(); - base.cpu = "pentium4".to_string(); - base.pre_link_args - .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pe".to_string()]); + base.cpu = "pentium4".into(); + base.pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".into(), "i386pe".into()]); base.max_atomic_width = Some(64); base.frame_pointer = FramePointer::Always; // Required for backtraces @@ -13,15 +12,15 @@ pub fn target() -> Target { base.pre_link_args .entry(LinkerFlavor::Gcc) .or_default() - .push("-Wl,--large-address-aware".to_string()); + .push("-Wl,--large-address-aware".into()); Target { - llvm_target: "i686-pc-windows-gnu".to_string(), + llvm_target: "i686-pc-windows-gnu".into(), pointer_width: 32, data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-f80:32-n8:16:32-a:0:32-S32" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs index e2f65e7a7c9..4c657fe908a 100644 --- a/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs @@ -2,16 +2,16 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::windows_uwp_msvc_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); Target { - llvm_target: "i686-pc-windows-msvc".to_string(), + llvm_target: "i686-pc-windows-msvc".into(), pointer_width: 32, data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-f80:128-n8:16:32-a:0:32-S32" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs b/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs index c7963dbde77..d51ed7c1f7a 100644 --- a/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs @@ -2,19 +2,19 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::vxworks_base::opts(); - base.cpu = "pentium4".to_string(); + base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "i686-unknown-linux-gnu".to_string(), + llvm_target: "i686-unknown-linux-gnu".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), + .into(), + arch: "x86".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/illumos_base.rs b/compiler/rustc_target/src/spec/illumos_base.rs index aeb40f7712e..68917171105 100644 --- a/compiler/rustc_target/src/spec/illumos_base.rs +++ b/compiler/rustc_target/src/spec/illumos_base.rs @@ -16,22 +16,22 @@ pub fn opts() -> TargetOptions { // FIXME: This should be replaced by a more complete and generic // mechanism for controlling the order of library arguments passed // to the linker. - "-lc".to_string(), + "-lc".into(), // LLVM will insert calls to the stack protector functions // "__stack_chk_fail" and "__stack_chk_guard" into code in native // object files. Some platforms include these symbols directly in // libc, but at least historically these have been provided in // libssp.so on illumos and Solaris systems. - "-lssp".to_string(), + "-lssp".into(), ], ); TargetOptions { - os: "illumos".to_string(), + os: "illumos".into(), dynamic_linking: true, executables: true, has_rpath: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], is_like_solaris: true, linker_is_gnu: false, limit_rdylib_exports: false, // Linker doesn't support this @@ -54,8 +54,8 @@ pub fn opts() -> TargetOptions { // // We want XPG6 behavior from libc and libm. See standards(5) //pre_link_objects_exe: vec![ - // "/usr/lib/amd64/values-Xc.o".to_string(), - // "/usr/lib/amd64/values-xpg6.o".to_string(), + // "/usr/lib/amd64/values-Xc.o".into(), + // "/usr/lib/amd64/values-xpg6.o".into(), //], ..Default::default() } diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs index 9e7973f63a9..dbc851cc1e1 100644 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ b/compiler/rustc_target/src/spec/l4re_base.rs @@ -3,14 +3,14 @@ use std::default::Default; pub fn opts() -> TargetOptions { TargetOptions { - os: "l4re".to_string(), - env: "uclibc".to_string(), + os: "l4re".into(), + env: "uclibc".into(), linker_flavor: LinkerFlavor::L4Bender, executables: true, panic_strategy: PanicStrategy::Abort, - linker: Some("l4-bender".to_string()), + linker: Some("l4-bender".into()), linker_is_gnu: false, - families: vec!["unix".to_string()], + families: vec!["unix".into()], ..Default::default() } } diff --git a/compiler/rustc_target/src/spec/linux_base.rs b/compiler/rustc_target/src/spec/linux_base.rs index e53d465e20d..135ca547d1d 100644 --- a/compiler/rustc_target/src/spec/linux_base.rs +++ b/compiler/rustc_target/src/spec/linux_base.rs @@ -2,10 +2,10 @@ use crate::spec::{RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { - os: "linux".to_string(), + os: "linux".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/linux_gnu_base.rs b/compiler/rustc_target/src/spec/linux_gnu_base.rs index 3d940ceaf02..8d6b3f18512 100644 --- a/compiler/rustc_target/src/spec/linux_gnu_base.rs +++ b/compiler/rustc_target/src/spec/linux_gnu_base.rs @@ -1,5 +1,5 @@ use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { - TargetOptions { env: "gnu".to_string(), ..super::linux_base::opts() } + TargetOptions { env: "gnu".into(), ..super::linux_base::opts() } } diff --git a/compiler/rustc_target/src/spec/linux_kernel_base.rs b/compiler/rustc_target/src/spec/linux_kernel_base.rs index a332e3b847a..0f5d85205f8 100644 --- a/compiler/rustc_target/src/spec/linux_kernel_base.rs +++ b/compiler/rustc_target/src/spec/linux_kernel_base.rs @@ -3,7 +3,7 @@ use crate::spec::{FramePointer, PanicStrategy, RelocModel, RelroLevel, StackProb pub fn opts() -> TargetOptions { TargetOptions { - env: "gnu".to_string(), + env: "gnu".into(), disable_redzone: true, panic_strategy: PanicStrategy::Abort, // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved diff --git a/compiler/rustc_target/src/spec/linux_musl_base.rs b/compiler/rustc_target/src/spec/linux_musl_base.rs index 5038a967d0a..207a87ab039 100644 --- a/compiler/rustc_target/src/spec/linux_musl_base.rs +++ b/compiler/rustc_target/src/spec/linux_musl_base.rs @@ -4,7 +4,7 @@ use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { let mut base = super::linux_base::opts(); - base.env = "musl".to_string(); + base.env = "musl".into(); base.pre_link_objects_fallback = crt_objects::pre_musl_fallback(); base.post_link_objects_fallback = crt_objects::post_musl_fallback(); base.crt_objects_fallback = Some(CrtObjectsFallback::Musl); diff --git a/compiler/rustc_target/src/spec/linux_uclibc_base.rs b/compiler/rustc_target/src/spec/linux_uclibc_base.rs index ef6d50656e4..4ba480ffecf 100644 --- a/compiler/rustc_target/src/spec/linux_uclibc_base.rs +++ b/compiler/rustc_target/src/spec/linux_uclibc_base.rs @@ -1,5 +1,5 @@ use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { - TargetOptions { env: "uclibc".to_string(), ..super::linux_base::opts() } + TargetOptions { env: "uclibc".into(), ..super::linux_base::opts() } } diff --git a/compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs index 5671b59c63f..ebd74012dcd 100644 --- a/compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs @@ -6,10 +6,10 @@ pub fn target() -> Target { base.max_atomic_width = Some(32); Target { - llvm_target: "m68k-unknown-linux-gnu".to_string(), + llvm_target: "m68k-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".to_string(), - arch: "m68k".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, + data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".into(), + arch: "m68k".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs b/compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs index 5991cd8bfa9..3c6ef52c6cd 100644 --- a/compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs +++ b/compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs @@ -5,21 +5,21 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "mips64r2".to_string(); - base.features = "+mips64r2,+soft-float".to_string(); + base.cpu = "mips64r2".into(); + base.features = "+mips64r2,+soft-float".into(); base.max_atomic_width = Some(64); base.crt_static_default = false; Target { // LLVM doesn't recognize "muslabi64" yet. - llvm_target: "mips64-unknown-linux-musl".to_string(), + llvm_target: "mips64-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), - arch: "mips64".to_string(), + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), options: TargetOptions { - abi: "abi64".to_string(), + abi: "abi64".into(), endian: Endian::Big, - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs index 161a27ab689..fc5dbd114e4 100644 --- a/compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs @@ -3,18 +3,18 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mips64-unknown-linux-gnuabi64".to_string(), + llvm_target: "mips64-unknown-linux-gnuabi64".into(), pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), - arch: "mips64".to_string(), + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), options: TargetOptions { - abi: "abi64".to_string(), + abi: "abi64".into(), endian: Endian::Big, // NOTE(mips64r2) matches C toolchain - cpu: "mips64r2".to_string(), - features: "+mips64r2".to_string(), + cpu: "mips64r2".into(), + features: "+mips64r2".into(), max_atomic_width: Some(64), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs index a8984645698..465e97a026c 100644 --- a/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs +++ b/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs @@ -3,19 +3,19 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "mips64r2".to_string(); - base.features = "+mips64r2".to_string(); + base.cpu = "mips64r2".into(); + base.features = "+mips64r2".into(); base.max_atomic_width = Some(64); Target { // LLVM doesn't recognize "muslabi64" yet. - llvm_target: "mips64-unknown-linux-musl".to_string(), + llvm_target: "mips64-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), - arch: "mips64".to_string(), + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), options: TargetOptions { - abi: "abi64".to_string(), + abi: "abi64".into(), endian: Endian::Big, - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs index 2f58560d450..e0d5f6f57f1 100644 --- a/compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs @@ -2,17 +2,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mips64el-unknown-linux-gnuabi64".to_string(), + llvm_target: "mips64el-unknown-linux-gnuabi64".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), - arch: "mips64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), options: TargetOptions { - abi: "abi64".to_string(), + abi: "abi64".into(), // NOTE(mips64r2) matches C toolchain - cpu: "mips64r2".to_string(), - features: "+mips64r2".to_string(), + cpu: "mips64r2".into(), + features: "+mips64r2".into(), max_atomic_width: Some(64), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs index 01c34bc3992..75575eb7eeb 100644 --- a/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs +++ b/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs @@ -2,15 +2,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "mips64r2".to_string(); - base.features = "+mips64r2".to_string(); + base.cpu = "mips64r2".into(); + base.features = "+mips64r2".into(); base.max_atomic_width = Some(64); Target { // LLVM doesn't recognize "muslabi64" yet. - llvm_target: "mips64el-unknown-linux-musl".to_string(), + llvm_target: "mips64el-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), - arch: "mips64".to_string(), - options: TargetOptions { abi: "abi64".to_string(), mcount: "_mcount".to_string(), ..base }, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), + options: TargetOptions { abi: "abi64".into(), mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs index b41b28cbc87..8df8b0b4c2c 100644 --- a/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs @@ -3,16 +3,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mips-unknown-linux-gnu".to_string(), + llvm_target: "mips-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { endian: Endian::Big, - cpu: "mips32r2".to_string(), - features: "+mips32r2,+fpxx,+nooddspreg".to_string(), + cpu: "mips32r2".into(), + features: "+mips32r2,+fpxx,+nooddspreg".into(), max_atomic_width: Some(32), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs index 3713af43d73..c2846313a9e 100644 --- a/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs @@ -3,15 +3,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "mips32r2".to_string(); - base.features = "+mips32r2,+soft-float".to_string(); + base.cpu = "mips32r2".into(); + base.features = "+mips32r2,+soft-float".into(); base.max_atomic_width = Some(32); base.crt_static_default = false; Target { - llvm_target: "mips-unknown-linux-musl".to_string(), + llvm_target: "mips-unknown-linux-musl".into(), pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs index 042ec9140fa..c59bb5fdd22 100644 --- a/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs +++ b/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs @@ -3,16 +3,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mips-unknown-linux-uclibc".to_string(), + llvm_target: "mips-unknown-linux-uclibc".into(), pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { endian: Endian::Big, - cpu: "mips32r2".to_string(), - features: "+mips32r2,+soft-float".to_string(), + cpu: "mips32r2".into(), + features: "+mips32r2,+soft-float".into(), max_atomic_width: Some(32), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_uclibc_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs index dc14e4bdf94..6857f7fd17d 100644 --- a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs +++ b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs @@ -6,30 +6,30 @@ const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); pub fn target() -> Target { let mut pre_link_args = LinkArgs::new(); - pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["--emit-relocs".to_string()]); + pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["--emit-relocs".into()]); Target { - llvm_target: "mipsel-sony-psp".to_string(), + llvm_target: "mipsel-sony-psp".into(), pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { - os: "psp".to_string(), - vendor: "sony".to_string(), + os: "psp".into(), + vendor: "sony".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - cpu: "mips2".to_string(), + cpu: "mips2".into(), executables: true, - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), relocation_model: RelocModel::Static, // PSP FPU only supports single precision floats. - features: "+single-float".to_string(), + features: "+single-float".into(), // PSP does not support trap-on-condition instructions. - llvm_args: vec!["-mno-check-zero-division".to_string()], + llvm_args: vec!["-mno-check-zero-division".into()], pre_link_args, - link_script: Some(LINKER_SCRIPT.to_string()), + link_script: Some(LINKER_SCRIPT.into()), ..Default::default() }, } diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs index 9cb2a13c7d4..01346e71a92 100644 --- a/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs @@ -2,16 +2,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mipsel-unknown-linux-gnu".to_string(), + llvm_target: "mipsel-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { - cpu: "mips32r2".to_string(), - features: "+mips32r2,+fpxx,+nooddspreg".to_string(), + cpu: "mips32r2".into(), + features: "+mips32r2,+fpxx,+nooddspreg".into(), max_atomic_width: Some(32), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs index 3374cdd4485..0e8f1a2c8e0 100644 --- a/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs @@ -2,15 +2,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "mips32r2".to_string(); - base.features = "+mips32r2,+soft-float".to_string(); + base.cpu = "mips32r2".into(); + base.features = "+mips32r2,+soft-float".into(); base.max_atomic_width = Some(32); base.crt_static_default = false; Target { - llvm_target: "mipsel-unknown-linux-musl".to_string(), + llvm_target: "mipsel-unknown-linux-musl".into(), pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), - options: TargetOptions { mcount: "_mcount".to_string(), ..base }, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs index 0831eb7a0a7..8342074586b 100644 --- a/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs +++ b/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs @@ -2,16 +2,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mipsel-unknown-linux-uclibc".to_string(), + llvm_target: "mipsel-unknown-linux-uclibc".into(), pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { - cpu: "mips32r2".to_string(), - features: "+mips32r2,+soft-float".to_string(), + cpu: "mips32r2".into(), + features: "+mips32r2,+soft-float".into(), max_atomic_width: Some(32), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_uclibc_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_none.rs b/compiler/rustc_target/src/spec/mipsel_unknown_none.rs index 5955baa31db..736af15cf44 100644 --- a/compiler/rustc_target/src/spec/mipsel_unknown_none.rs +++ b/compiler/rustc_target/src/spec/mipsel_unknown_none.rs @@ -7,18 +7,18 @@ use crate::spec::{PanicStrategy, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mipsel-unknown-none".to_string(), + llvm_target: "mipsel-unknown-none".into(), pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - cpu: "mips32r2".to_string(), - features: "+mips32r2,+soft-float,+noabicalls".to_string(), + cpu: "mips32r2".into(), + features: "+mips32r2,+soft-float,+noabicalls".into(), max_atomic_width: Some(32), executables: true, - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, emit_debug_gdb_scripts: false, diff --git a/compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs index a81c90fe0cd..1e066b271e2 100644 --- a/compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs @@ -3,16 +3,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mipsisa32r6-unknown-linux-gnu".to_string(), + llvm_target: "mipsisa32r6-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { endian: Endian::Big, - cpu: "mips32r6".to_string(), - features: "+mips32r6".to_string(), + cpu: "mips32r6".into(), + features: "+mips32r6".into(), max_atomic_width: Some(32), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs index 06a5f40d69b..4785929c100 100644 --- a/compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs @@ -2,16 +2,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mipsisa32r6el-unknown-linux-gnu".to_string(), + llvm_target: "mipsisa32r6el-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), - arch: "mips".to_string(), + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), options: TargetOptions { - cpu: "mips32r6".to_string(), - features: "+mips32r6".to_string(), + cpu: "mips32r6".into(), + features: "+mips32r6".into(), max_atomic_width: Some(32), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs index 80a155a4865..766ac768064 100644 --- a/compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs @@ -3,18 +3,18 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mipsisa64r6-unknown-linux-gnuabi64".to_string(), + llvm_target: "mipsisa64r6-unknown-linux-gnuabi64".into(), pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), - arch: "mips64".to_string(), + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), options: TargetOptions { - abi: "abi64".to_string(), + abi: "abi64".into(), endian: Endian::Big, // NOTE(mips64r6) matches C toolchain - cpu: "mips64r6".to_string(), - features: "+mips64r6".to_string(), + cpu: "mips64r6".into(), + features: "+mips64r6".into(), max_atomic_width: Some(64), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs index 58f9862715f..d2b07c654dc 100644 --- a/compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs @@ -2,17 +2,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "mipsisa64r6el-unknown-linux-gnuabi64".to_string(), + llvm_target: "mipsisa64r6el-unknown-linux-gnuabi64".into(), pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), - arch: "mips64".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), options: TargetOptions { - abi: "abi64".to_string(), + abi: "abi64".into(), // NOTE(mips64r6) matches C toolchain - cpu: "mips64r6".to_string(), - features: "+mips64r6".to_string(), + cpu: "mips64r6".into(), + features: "+mips64r6".into(), max_atomic_width: Some(64), - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 4953dafe89b..0c5bddad72a 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -40,6 +40,7 @@ use crate::spec::crt_objects::{CrtObjects, CrtObjectsFallback}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_serialize::json::{Json, ToJson}; use rustc_span::symbol::{sym, Symbol}; +use std::borrow::Cow; use std::collections::BTreeMap; use std::convert::TryFrom; use std::iter::FromIterator; @@ -1064,14 +1065,14 @@ impl TargetWarnings { #[derive(PartialEq, Clone, Debug)] pub struct Target { /// Target triple to pass to LLVM. - pub llvm_target: String, + pub llvm_target: Cow<'static, str>, /// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable. pub pointer_width: u32, /// Architecture to use for ABI considerations. Valid options include: "x86", /// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others. - pub arch: String, + pub arch: Cow<'static, str>, /// [Data layout](https://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM. - pub data_layout: String, + pub data_layout: Cow<'static, str>, /// Optional settings with defaults. pub options: TargetOptions, } @@ -1103,25 +1104,25 @@ pub struct TargetOptions { /// Used as the `target_endian` `cfg` variable. Defaults to little endian. pub endian: Endian, /// Width of c_int type. Defaults to "32". - pub c_int_width: String, + pub c_int_width: Cow<'static, str>, /// OS name to use for conditional compilation (`target_os`). Defaults to "none". /// "none" implies a bare metal target without `std` library. /// A couple of targets having `std` also use "unknown" as an `os` value, /// but they are exceptions. - pub os: String, + pub os: Cow<'static, str>, /// Environment name to use for conditional compilation (`target_env`). Defaults to "". - pub env: String, + pub env: Cow<'static, str>, /// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"` /// or `"eabihf"`. Defaults to "". - pub abi: String, + pub abi: Cow<'static, str>, /// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown". - pub vendor: String, + pub vendor: Cow<'static, str>, /// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed /// on the command line. Defaults to `LinkerFlavor::Gcc`. pub linker_flavor: LinkerFlavor, /// Linker to invoke - pub linker: Option, + pub linker: Option>, /// LLD flavor used if `lld` (or `rust-lld`) is specified as a linker /// without clarifying its flavor in any way. @@ -1156,23 +1157,23 @@ pub struct TargetOptions { /// Optional link script applied to `dylib` and `executable` crate types. /// This is a string containing the script, not a path. Can only be applied /// to linkers where `linker_is_gnu` is true. - pub link_script: Option, + pub link_script: Option>, /// Environment variables to be set for the linker invocation. - pub link_env: Vec<(String, String)>, + pub link_env: Vec<(Cow<'static, str>, Cow<'static, str>)>, /// Environment variables to be removed for the linker invocation. - pub link_env_remove: Vec, + pub link_env_remove: Vec>, /// Extra arguments to pass to the external assembler (when used) - pub asm_args: Vec, + pub asm_args: Vec>, /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults /// to "generic". - pub cpu: String, + pub cpu: Cow<'static, str>, /// Default target features to pass to LLVM. These features will *always* be /// passed, and cannot be disabled even via `-C`. Corresponds to `llc /// -mattr=$features`. - pub features: String, + pub features: Cow<'static, str>, /// Whether dynamic linking is available on this target. Defaults to false. pub dynamic_linking: bool, /// If dynamic linking is available, whether only cdylibs are supported. @@ -1196,21 +1197,21 @@ pub struct TargetOptions { /// Emit each function in its own section. Defaults to true. pub function_sections: bool, /// String to prepend to the name of every dynamic library. Defaults to "lib". - pub dll_prefix: String, + pub dll_prefix: Cow<'static, str>, /// String to append to the name of every dynamic library. Defaults to ".so". - pub dll_suffix: String, + pub dll_suffix: Cow<'static, str>, /// String to append to the name of every executable. - pub exe_suffix: String, + pub exe_suffix: Cow<'static, str>, /// String to prepend to the name of every static library. Defaults to "lib". - pub staticlib_prefix: String, + pub staticlib_prefix: Cow<'static, str>, /// String to append to the name of every static library. Defaults to ".a". - pub staticlib_suffix: String, + pub staticlib_suffix: Cow<'static, str>, /// Values of the `target_family` cfg set for this target. /// /// Common options are: "unix", "windows". Defaults to no families. /// /// See . - pub families: Vec, + pub families: Vec>, /// Whether the target toolchain's ABI supports returning small structs as an integer. pub abi_return_struct_as_int: bool, /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS, @@ -1282,7 +1283,7 @@ pub struct TargetOptions { /// LLVM to assemble an archive or fall back to the system linker, and /// currently only "gnu" is used to fall into LLVM. Unknown strings cause /// the system linker to be used. - pub archive_format: String, + pub archive_format: Cow<'static, str>, /// Is asm!() allowed? Defaults to true. pub allow_asm: bool, /// Whether the runtime startup code requires the `main` function be passed @@ -1298,7 +1299,7 @@ pub struct TargetOptions { /// Whether the target requires that emitted object code includes bitcode. pub forces_embed_bitcode: bool, /// Content of the LLVM cmdline section associated with embedded bitcode. - pub bitcode_llvm_cmdline: String, + pub bitcode_llvm_cmdline: Cow<'static, str>, /// Don't use this field; instead use the `.min_atomic_width()` method. pub min_atomic_width: Option, @@ -1370,7 +1371,7 @@ pub struct TargetOptions { /// If set, have the linker export exactly these symbols, instead of using /// the usual logic to figure this out from the crate itself. - pub override_export_symbols: Option>, + pub override_export_symbols: Option>>, /// Determines how or whether the MergeFunctions LLVM pass should run for /// this target. Either "disabled", "trampolines", or "aliases". @@ -1381,16 +1382,16 @@ pub struct TargetOptions { pub merge_functions: MergeFunctions, /// Use platform dependent mcount function - pub mcount: String, + pub mcount: Cow<'static, str>, /// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers - pub llvm_abiname: String, + pub llvm_abiname: Cow<'static, str>, /// Whether or not RelaxElfRelocation flag will be passed to the linker pub relax_elf_relocations: bool, /// Additional arguments to pass to LLVM, similar to the `-C llvm-args` codegen option. - pub llvm_args: Vec, + pub llvm_args: Vec>, /// Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults /// to false (uses .init_array). @@ -1437,20 +1438,20 @@ impl Default for TargetOptions { TargetOptions { is_builtin: false, endian: Endian::Little, - c_int_width: "32".to_string(), - os: "none".to_string(), - env: String::new(), - abi: String::new(), - vendor: "unknown".to_string(), + c_int_width: "32".into(), + os: "none".into(), + env: Cow::from(""), + abi: Cow::from(""), + vendor: "unknown".into(), linker_flavor: LinkerFlavor::Gcc, - linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.to_string()), + linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()), lld_flavor: LldFlavor::Ld, pre_link_args: LinkArgs::new(), post_link_args: LinkArgs::new(), link_script: None, asm_args: Vec::new(), - cpu: "generic".to_string(), - features: String::new(), + cpu: "generic".into(), + features: Cow::from(""), dynamic_linking: false, only_cdylib: false, executables: false, @@ -1460,11 +1461,11 @@ impl Default for TargetOptions { disable_redzone: false, frame_pointer: FramePointer::MayOmit, function_sections: true, - dll_prefix: "lib".to_string(), - dll_suffix: ".so".to_string(), - exe_suffix: String::new(), - staticlib_prefix: "lib".to_string(), - staticlib_suffix: ".a".to_string(), + dll_prefix: "lib".into(), + dll_suffix: ".so".into(), + exe_suffix: Cow::from(""), + staticlib_prefix: "lib".into(), + staticlib_suffix: ".a".into(), families: Vec::new(), abi_return_struct_as_int: false, is_like_osx: false, @@ -1493,13 +1494,13 @@ impl Default for TargetOptions { late_link_args_static: LinkArgs::new(), link_env: Vec::new(), link_env_remove: Vec::new(), - archive_format: "gnu".to_string(), + archive_format: "gnu".into(), main_needs_argc_argv: true, allow_asm: true, has_thread_local: false, obj_is_bitcode: false, forces_embed_bitcode: false, - bitcode_llvm_cmdline: String::new(), + bitcode_llvm_cmdline: Cow::from(""), min_atomic_width: None, max_atomic_width: None, atomic_cas: true, @@ -1522,8 +1523,8 @@ impl Default for TargetOptions { limit_rdylib_exports: true, override_export_symbols: None, merge_functions: MergeFunctions::Aliases, - mcount: "mcount".to_string(), - llvm_abiname: "".to_string(), + mcount: "mcount".into(), + llvm_abiname: "".into(), relax_elf_relocations: false, llvm_args: vec![], use_ctors_section: false, @@ -1671,12 +1672,12 @@ impl Target { }; let mut base = Target { - llvm_target: get_req_field("llvm-target")?, + llvm_target: get_req_field("llvm-target")?.into(), pointer_width: get_req_field("target-pointer-width")? .parse::() .map_err(|_| "target-pointer-width must be an integer".to_string())?, - data_layout: get_req_field("data-layout")?, - arch: get_req_field("arch")?, + data_layout: get_req_field("data-layout")?.into(), + arch: get_req_field("arch")?.into(), options: Default::default(), }; @@ -1685,13 +1686,13 @@ impl Target { macro_rules! key { ($key_name:ident) => ( { let name = (stringify!($key_name)).replace("_", "-"); - if let Some(s) = obj.remove_key(&name).and_then(|j| Json::as_string(&j).map(str::to_string)) { + if let Some(s) = obj.remove_key(&name).and_then(|j| Json::as_string(&j).map(str::to_string).map(Cow::from)) { base.$key_name = s; } } ); ($key_name:ident = $json_name:expr) => ( { let name = $json_name; - if let Some(s) = obj.remove_key(&name).and_then(|j| Json::as_string(&j).map(str::to_string)) { + if let Some(s) = obj.remove_key(&name).and_then(|j| Json::as_string(&j).map(str::to_string).map(Cow::from)) { base.$key_name = s; } } ); @@ -1711,7 +1712,7 @@ impl Target { let name = (stringify!($key_name)).replace("_", "-"); if let Some(s) = obj.remove_key(&name).and_then(|j| Json::as_u64(&j)) { if s < 1 || s > 5 { - return Err("Not a valid DWARF version number".to_string()); + return Err("Not a valid DWARF version number".into()); } base.$key_name = Some(s as u32); } @@ -1813,7 +1814,7 @@ impl Target { if let Some(j) = obj.remove_key(&name){ if let Some(v) = Json::as_array(&j) { base.$key_name = v.iter() - .map(|a| a.as_string().unwrap().to_string()) + .map(|a| a.as_string().unwrap().to_string().into()) .collect(); } else { incorrect_type.push(name) @@ -1825,7 +1826,7 @@ impl Target { if let Some(j) = obj.remove_key(&name) { if let Some(v) = Json::as_array(&j) { base.$key_name = Some(v.iter() - .map(|a| a.as_string().unwrap().to_string()) + .map(|a| a.as_string().unwrap().to_string().into()) .collect()); } else { incorrect_type.push(name) @@ -1837,7 +1838,7 @@ impl Target { if let Some(o) = obj.remove_key(&name[..]) { base.$key_name = o .as_string() - .map(|s| s.to_string() ); + .map(|s| s.to_string().into()); } } ); ($key_name:ident, LldFlavor) => ( { @@ -1931,7 +1932,7 @@ impl Target { .map(|(i,s)| { let s = s.as_string().ok_or_else(|| format!("{}.{}[{}]: expected a JSON string", name, k, i))?; - Ok(s.to_owned()) + Ok(s.to_string().into()) }) .collect::, String>>()?; @@ -1958,7 +1959,7 @@ impl Target { .map(|(i,s)| { let s = s.as_string().ok_or_else(|| format!("{}.{}[{}]: expected a JSON string", name, k, i))?; - Ok(s.to_owned()) + Ok(s.into()) }) .collect::, String>>()?; @@ -1977,7 +1978,7 @@ impl Target { if p.len() == 2 { let k = p[0].to_string(); let v = p[1].to_string(); - base.$key_name.push((k, v)); + base.$key_name.push((k.into(), v.into())); } } } @@ -2000,10 +2001,10 @@ impl Target { if let Some(value) = obj.remove_key("target-family") { if let Some(v) = Json::as_array(&value) { base.$key_name = v.iter() - .map(|a| a.as_string().unwrap().to_string()) + .map(|a| a.as_string().unwrap().to_string().into()) .collect(); } else if let Some(v) = Json::as_string(&value) { - base.$key_name = vec![v.to_string()]; + base.$key_name = vec![v.to_string().into()]; } } } ); @@ -2013,7 +2014,7 @@ impl Target { if let Some(s) = Json::as_string(&j) { base.endian = s.parse()?; } else { - incorrect_type.push("target-endian".to_string()) + incorrect_type.push("target-endian".into()) } } @@ -2023,7 +2024,7 @@ impl Target { .parse() .map_err(|()| format!("'{}' is not a valid value for frame-pointer", s))?; } else { - incorrect_type.push("frame-pointer".to_string()) + incorrect_type.push("frame-pointer".into()) } } @@ -2128,7 +2129,7 @@ impl Target { if base.is_builtin { // This can cause unfortunate ICEs later down the line. - return Err("may not set is_builtin for targets not built-in".to_string()); + return Err("may not set is_builtin for targets not built-in".into()); } // Each field should have been read using `Json::remove_key` so any keys remaining are unused. let remaining_keys = obj.as_object().ok_or("Expected JSON object for target")?.keys(); @@ -2232,7 +2233,7 @@ impl ToJson for Target { }}; ($attr:ident, $key_name:expr) => {{ let name = $key_name; - d.insert(name.to_string(), self.$attr.to_json()); + d.insert(name.into(), self.$attr.to_json()); }}; } @@ -2246,7 +2247,7 @@ impl ToJson for Target { ($attr:ident, $key_name:expr) => {{ let name = $key_name; if default.$attr != self.$attr { - d.insert(name.to_string(), self.$attr.to_json()); + d.insert(name.into(), self.$attr.to_json()); } }}; (link_args - $attr:ident) => {{ @@ -2255,7 +2256,7 @@ impl ToJson for Target { let obj = self .$attr .iter() - .map(|(k, v)| (k.desc().to_owned(), v.clone())) + .map(|(k, v)| (k.desc().to_string(), v.clone())) .collect::>(); d.insert(name, obj.to_json()); } @@ -2266,7 +2267,7 @@ impl ToJson for Target { let obj = self .$attr .iter() - .map(|&(ref k, ref v)| k.clone() + "=" + &v) + .map(|&(ref k, ref v)| format!("{k}={v}")) .collect::>(); d.insert(name, obj.to_json()); } @@ -2379,7 +2380,7 @@ impl ToJson for Target { target_option_val!(supports_stack_protector); if let Some(abi) = self.default_adjusted_cabi { - d.insert("default-adjusted-cabi".to_string(), Abi::name(abi).to_json()); + d.insert("default-adjusted-cabi".into(), Abi::name(abi).to_json()); } Json::Object(d) @@ -2396,7 +2397,7 @@ pub enum TargetTriple { impl TargetTriple { /// Creates a target triple from the passed target triple string. pub fn from_triple(triple: &str) -> Self { - TargetTriple::TargetTriple(triple.to_string()) + TargetTriple::TargetTriple(triple.into()) } /// Creates a target triple from the passed target path. @@ -2434,7 +2435,7 @@ impl TargetTriple { let hash = hasher.finish(); format!("{}-{}", triple, hash) } else { - triple.to_owned() + triple.into() } } } diff --git a/compiler/rustc_target/src/spec/msp430_none_elf.rs b/compiler/rustc_target/src/spec/msp430_none_elf.rs index 6e3a241a86e..2dd23b7d3c3 100644 --- a/compiler/rustc_target/src/spec/msp430_none_elf.rs +++ b/compiler/rustc_target/src/spec/msp430_none_elf.rs @@ -2,21 +2,21 @@ use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "msp430-none-elf".to_string(), + llvm_target: "msp430-none-elf".into(), pointer_width: 16, - data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".to_string(), - arch: "msp430".to_string(), + data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".into(), + arch: "msp430".into(), options: TargetOptions { - c_int_width: "16".to_string(), + c_int_width: "16".into(), executables: true, // The LLVM backend currently can't generate object files. To // workaround this LLVM generates assembly files which then we feed // to gcc to get object files. For this reason we have a hard // dependency on this specific gcc. - asm_args: vec!["-mcpu=msp430".to_string()], - linker: Some("msp430-elf-gcc".to_string()), + asm_args: vec!["-mcpu=msp430".into()], + linker: Some("msp430-elf-gcc".into()), linker_is_gnu: false, // There are no atomic CAS instructions available in the MSP430 diff --git a/compiler/rustc_target/src/spec/msvc_base.rs b/compiler/rustc_target/src/spec/msvc_base.rs index f1ed4c154d2..00cc9620243 100644 --- a/compiler/rustc_target/src/spec/msvc_base.rs +++ b/compiler/rustc_target/src/spec/msvc_base.rs @@ -4,7 +4,7 @@ pub fn opts() -> TargetOptions { let pre_link_args_msvc = vec![ // Suppress the verbose logo and authorship debugging output, which would needlessly // clog any log files. - "/NOLOGO".to_string(), + "/NOLOGO".into(), ]; let mut pre_link_args = LinkArgs::new(); pre_link_args.insert(LinkerFlavor::Msvc, pre_link_args_msvc.clone()); diff --git a/compiler/rustc_target/src/spec/netbsd_base.rs b/compiler/rustc_target/src/spec/netbsd_base.rs index 6bb6083d47c..c20eb163dda 100644 --- a/compiler/rustc_target/src/spec/netbsd_base.rs +++ b/compiler/rustc_target/src/spec/netbsd_base.rs @@ -2,10 +2,10 @@ use crate::spec::{RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { - os: "netbsd".to_string(), + os: "netbsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], no_default_libraries: false, has_rpath: true, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs index ba32a312910..9d94ed8aa48 100644 --- a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs @@ -2,21 +2,21 @@ use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOpt pub fn target() -> Target { Target { - arch: "nvptx64".to_string(), - data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".to_string(), - llvm_target: "nvptx64-nvidia-cuda".to_string(), + arch: "nvptx64".into(), + data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".into(), + llvm_target: "nvptx64-nvidia-cuda".into(), pointer_width: 64, options: TargetOptions { - os: "cuda".to_string(), - vendor: "nvidia".to_string(), + os: "cuda".into(), + vendor: "nvidia".into(), linker_flavor: LinkerFlavor::PtxLinker, // The linker can be installed from `crates.io`. - linker: Some("rust-ptx-linker".to_string()), + linker: Some("rust-ptx-linker".into()), linker_is_gnu: false, // With `ptx-linker` approach, it can be later overridden via link flags. - cpu: "sm_30".to_string(), + cpu: "sm_30".into(), // FIXME: create tests for the atomics. max_atomic_width: Some(64), @@ -36,9 +36,9 @@ pub fn target() -> Target { obj_is_bitcode: true, // Convenient and predicable naming scheme. - dll_prefix: "".to_string(), - dll_suffix: ".ptx".to_string(), - exe_suffix: ".ptx".to_string(), + dll_prefix: "".into(), + dll_suffix: ".ptx".into(), + exe_suffix: ".ptx".into(), // Disable MergeFunctions LLVM optimisation pass because it can // produce kernel functions that call other kernel functions. diff --git a/compiler/rustc_target/src/spec/openbsd_base.rs b/compiler/rustc_target/src/spec/openbsd_base.rs index 70e9e4aed92..a913be93861 100644 --- a/compiler/rustc_target/src/spec/openbsd_base.rs +++ b/compiler/rustc_target/src/spec/openbsd_base.rs @@ -2,10 +2,10 @@ use crate::spec::{FramePointer, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { - os: "openbsd".to_string(), + os: "openbsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], has_rpath: true, abi_return_struct_as_int: true, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs index b3d6b7c6107..595769c4bfa 100644 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs @@ -3,15 +3,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::freebsd_base::opts(); - base.cpu = "ppc64".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "ppc64".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "powerpc64-unknown-freebsd".to_string(), + llvm_target: "powerpc64-unknown-freebsd".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64".to_string(), - arch: "powerpc64".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, + data_layout: "E-m:e-i64:64-n32:64".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs index f10d4d49bb9..24d5d187e1a 100644 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs @@ -3,8 +3,8 @@ use crate::spec::{LinkerFlavor, RelroLevel, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); - base.cpu = "ppc64".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "ppc64".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); // ld.so in at least RHEL6 on ppc64 has a bug related to BIND_NOW, so only enable partial RELRO @@ -12,10 +12,10 @@ pub fn target() -> Target { base.relro_level = RelroLevel::Partial; Target { - llvm_target: "powerpc64-unknown-linux-gnu".to_string(), + llvm_target: "powerpc64-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".to_string(), - arch: "powerpc64".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, + data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs index 611621727bd..0f465ccfe77 100644 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs @@ -3,15 +3,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "ppc64".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "ppc64".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "powerpc64-unknown-linux-musl".to_string(), + llvm_target: "powerpc64-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".to_string(), - arch: "powerpc64".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, + data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs index 9c63997ce2f..491d344aedb 100644 --- a/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs @@ -3,15 +3,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::vxworks_base::opts(); - base.cpu = "ppc64".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "ppc64".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "powerpc64-unknown-linux-gnu".to_string(), + llvm_target: "powerpc64-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".to_string(), - arch: "powerpc64".to_string(), + data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), options: TargetOptions { endian: Endian::Big, ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs index 283e9f744cb..b198e667ccc 100644 --- a/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs @@ -2,15 +2,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::freebsd_base::opts(); - base.cpu = "ppc64le".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "ppc64le".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "powerpc64le-unknown-freebsd".to_string(), + llvm_target: "powerpc64le-unknown-freebsd".into(), pointer_width: 64, - data_layout: "e-m:e-i64:64-n32:64".to_string(), - arch: "powerpc64".to_string(), - options: TargetOptions { mcount: "_mcount".to_string(), ..base }, + data_layout: "e-m:e-i64:64-n32:64".into(), + arch: "powerpc64".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs index f645eceadfe..09e3936db26 100644 --- a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs @@ -2,15 +2,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); - base.cpu = "ppc64le".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "ppc64le".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "powerpc64le-unknown-linux-gnu".to_string(), + llvm_target: "powerpc64le-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".to_string(), - arch: "powerpc64".to_string(), - options: TargetOptions { mcount: "_mcount".to_string(), ..base }, + data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs index 934371fb221..8a947b091cb 100644 --- a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs @@ -2,15 +2,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "ppc64le".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "ppc64le".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "powerpc64le-unknown-linux-musl".to_string(), + llvm_target: "powerpc64le-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".to_string(), - arch: "powerpc64".to_string(), - options: TargetOptions { mcount: "_mcount".to_string(), ..base }, + data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs index e11318027d5..c27b84775df 100644 --- a/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs @@ -3,24 +3,24 @@ use crate::spec::{LinkerFlavor, RelocModel, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::freebsd_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); // Extra hint to linker that we are generating secure-PLT code. base.pre_link_args .entry(LinkerFlavor::Gcc) .or_default() - .push("--target=powerpc-unknown-freebsd13.0".to_string()); + .push("--target=powerpc-unknown-freebsd13.0".into()); base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-freebsd13.0".to_string(), + llvm_target: "powerpc-unknown-freebsd13.0".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), options: TargetOptions { endian: Endian::Big, - features: "+secure-plt".to_string(), + features: "+secure-plt".into(), relocation_model: RelocModel::Pic, - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs index 21ffdd2d160..88f61500e3c 100644 --- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs @@ -3,14 +3,14 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-linux-gnu".to_string(), + llvm_target: "powerpc-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs index 362d8a104e4..3ee548750b9 100644 --- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs +++ b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs @@ -3,18 +3,18 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mspe".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mspe".into()); base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-linux-gnuspe".to_string(), + llvm_target: "powerpc-unknown-linux-gnuspe".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), options: TargetOptions { - abi: "spe".to_string(), + abi: "spe".into(), endian: Endian::Big, - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs index 9633705db6d..ce33c787f33 100644 --- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs @@ -3,14 +3,14 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-linux-musl".to_string(), + llvm_target: "powerpc-unknown-linux-musl".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs index 4cc5224fae3..998225f4dae 100644 --- a/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs @@ -3,14 +3,14 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::netbsd_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-netbsd".to_string(), + llvm_target: "powerpc-unknown-netbsd".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "__mcount".to_string(), ..base }, + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs index c17183faa7a..ad2c3d40f35 100644 --- a/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs @@ -7,10 +7,10 @@ pub fn target() -> Target { base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-openbsd".to_string(), + llvm_target: "powerpc-unknown-openbsd".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs index 2f0a6ca44a0..76709cec591 100644 --- a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs @@ -3,15 +3,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::vxworks_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string()); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("--secure-plt".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("--secure-plt".into()); base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-linux-gnu".to_string(), + llvm_target: "powerpc-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), - options: TargetOptions { endian: Endian::Big, features: "+secure-plt".to_string(), ..base }, + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs index a2b85f7dd86..7b5d1242c52 100644 --- a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs +++ b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs @@ -3,20 +3,20 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::vxworks_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mspe".to_string()); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("--secure-plt".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mspe".into()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("--secure-plt".into()); base.max_atomic_width = Some(32); Target { - llvm_target: "powerpc-unknown-linux-gnuspe".to_string(), + llvm_target: "powerpc-unknown-linux-gnuspe".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), + data_layout: "E-m:e-p:32:32-i64:64-n32".into(), + arch: "powerpc".into(), options: TargetOptions { - abi: "spe".to_string(), + abi: "spe".into(), endian: Endian::Big, // feature msync would disable instruction 'fsync' which is not supported by fsl_p1p2 - features: "+secure-plt,+msync".to_string(), + features: "+secure-plt,+msync".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/redox_base.rs b/compiler/rustc_target/src/spec/redox_base.rs index bcb536b37a1..51774059c10 100644 --- a/compiler/rustc_target/src/spec/redox_base.rs +++ b/compiler/rustc_target/src/spec/redox_base.rs @@ -2,11 +2,11 @@ use crate::spec::{RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { - os: "redox".to_string(), - env: "relibc".to_string(), + os: "redox".into(), + env: "relibc".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs index a9cdad1a8b1..bffd377bc4a 100644 --- a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs @@ -2,15 +2,15 @@ use crate::spec::{CodeModel, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "riscv32-unknown-linux-gnu".to_string(), + llvm_target: "riscv32-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), - arch: "riscv32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + arch: "riscv32".into(), options: TargetOptions { code_model: Some(CodeModel::Medium), - cpu: "generic-rv32".to_string(), - features: "+m,+a,+f,+d,+c".to_string(), - llvm_abiname: "ilp32d".to_string(), + cpu: "generic-rv32".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "ilp32d".into(), max_atomic_width: Some(32), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs index a64a82d55b9..c9f3acffb77 100644 --- a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs @@ -2,15 +2,15 @@ use crate::spec::{CodeModel, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "riscv32-unknown-linux-musl".to_string(), + llvm_target: "riscv32-unknown-linux-musl".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), - arch: "riscv32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + arch: "riscv32".into(), options: TargetOptions { code_model: Some(CodeModel::Medium), - cpu: "generic-rv32".to_string(), - features: "+m,+a,+f,+d,+c".to_string(), - llvm_abiname: "ilp32d".to_string(), + cpu: "generic-rv32".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "ilp32d".into(), max_atomic_width: Some(32), ..super::linux_musl_base::opts() }, diff --git a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs index 16d37218f41..7124e2df9b3 100644 --- a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs @@ -3,15 +3,15 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), - llvm_target: "riscv32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), pointer_width: 32, - arch: "riscv32".to_string(), + arch: "riscv32".into(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_string()), - cpu: "generic-rv32".to_string(), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), max_atomic_width: Some(0), atomic_cas: false, executables: true, diff --git a/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs index 0357a94914f..508982eed68 100644 --- a/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs @@ -3,18 +3,18 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), - llvm_target: "riscv32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), pointer_width: 32, - arch: "riscv32".to_string(), + arch: "riscv32".into(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_string()), - cpu: "generic-rv32".to_string(), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), max_atomic_width: Some(0), atomic_cas: false, - features: "+m".to_string(), + features: "+m".into(), executables: true, panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs index b53bae6cb56..f2bd6249f0a 100644 --- a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs @@ -3,17 +3,17 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), - llvm_target: "riscv32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), pointer_width: 32, - arch: "riscv32".to_string(), + arch: "riscv32".into(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_string()), - cpu: "generic-rv32".to_string(), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), max_atomic_width: Some(32), - features: "+m,+a,+c".to_string(), + features: "+m,+a,+c".into(), executables: true, panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs index d506e7f6aac..d9f40d51069 100644 --- a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs @@ -3,19 +3,19 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), - llvm_target: "riscv32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), pointer_width: 32, - arch: "riscv32".to_string(), + arch: "riscv32".into(), options: TargetOptions { - families: vec!["unix".to_string()], - os: "espidf".to_string(), - env: "newlib".to_string(), - vendor: "espressif".to_string(), + families: vec!["unix".into()], + os: "espidf".into(), + env: "newlib".into(), + vendor: "espressif".into(), linker_flavor: LinkerFlavor::Gcc, - linker: Some("riscv32-esp-elf-gcc".to_string()), - cpu: "generic-rv32".to_string(), + linker: Some("riscv32-esp-elf-gcc".into()), + cpu: "generic-rv32".into(), // While the RiscV32IMC architecture does not natively support atomics, ESP-IDF does support // the __atomic* and __sync* GCC builtins, so setting `max_atomic_width` to `Some(64)` @@ -25,7 +25,7 @@ pub fn target() -> Target { max_atomic_width: Some(64), atomic_cas: true, - features: "+m,+c".to_string(), + features: "+m,+c".into(), executables: true, panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs index 9a23def1996..4216968cb77 100644 --- a/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs @@ -3,18 +3,18 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), - llvm_target: "riscv32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), pointer_width: 32, - arch: "riscv32".to_string(), + arch: "riscv32".into(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_string()), - cpu: "generic-rv32".to_string(), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), max_atomic_width: Some(0), atomic_cas: false, - features: "+m,+c".to_string(), + features: "+m,+c".into(), executables: true, panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs index 1ea1b9bea2e..0539eca6c1f 100644 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs @@ -2,15 +2,15 @@ use crate::spec::{CodeModel, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "riscv64-unknown-freebsd".to_string(), + llvm_target: "riscv64-unknown-freebsd".into(), pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), - arch: "riscv64".to_string(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + arch: "riscv64".into(), options: TargetOptions { code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".to_string(), - features: "+m,+a,+f,+d,+c".to_string(), - llvm_abiname: "lp64d".to_string(), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), max_atomic_width: Some(64), ..super::freebsd_base::opts() }, diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs index 02d44b5ed7e..7d1bf228c37 100644 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs @@ -2,15 +2,15 @@ use crate::spec::{CodeModel, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "riscv64-unknown-linux-gnu".to_string(), + llvm_target: "riscv64-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), - arch: "riscv64".to_string(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + arch: "riscv64".into(), options: TargetOptions { code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".to_string(), - features: "+m,+a,+f,+d,+c".to_string(), - llvm_abiname: "lp64d".to_string(), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), max_atomic_width: Some(64), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs index 3754750e48d..f04f8a48bc8 100644 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs @@ -2,15 +2,15 @@ use crate::spec::{CodeModel, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "riscv64-unknown-linux-musl".to_string(), + llvm_target: "riscv64-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), - arch: "riscv64".to_string(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + arch: "riscv64".into(), options: TargetOptions { code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".to_string(), - features: "+m,+a,+f,+d,+c".to_string(), - llvm_abiname: "lp64d".to_string(), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), max_atomic_width: Some(64), ..super::linux_musl_base::opts() }, diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs index f527a6cd26d..2a93459ef4f 100644 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs @@ -3,18 +3,18 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), - llvm_target: "riscv64".to_string(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + llvm_target: "riscv64".into(), pointer_width: 64, - arch: "riscv64".to_string(), + arch: "riscv64".into(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_string()), - llvm_abiname: "lp64d".to_string(), - cpu: "generic-rv64".to_string(), + linker: Some("rust-lld".into()), + llvm_abiname: "lp64d".into(), + cpu: "generic-rv64".into(), max_atomic_width: Some(64), - features: "+m,+a,+f,+d,+c".to_string(), + features: "+m,+a,+f,+d,+c".into(), executables: true, panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs index 8b1ba88e67f..6a8d8a97de6 100644 --- a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs @@ -3,17 +3,17 @@ use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel}; pub fn target() -> Target { Target { - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), - llvm_target: "riscv64".to_string(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + llvm_target: "riscv64".into(), pointer_width: 64, - arch: "riscv64".to_string(), + arch: "riscv64".into(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_string()), - cpu: "generic-rv64".to_string(), + linker: Some("rust-lld".into()), + cpu: "generic-rv64".into(), max_atomic_width: Some(64), - features: "+m,+a,+c".to_string(), + features: "+m,+a,+c".into(), executables: true, panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs index 4eeea9bedfb..8757bbed8ad 100644 --- a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs @@ -5,19 +5,19 @@ pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); base.endian = Endian::Big; // z10 is the oldest CPU supported by LLVM - base.cpu = "z10".to_string(); + base.cpu = "z10".into(); // FIXME: The data_layout string below and the ABI implementation in // cabi_s390x.rs are for now hard-coded to assume the no-vector ABI. // Pass the -vector feature string to LLVM to respect this assumption. - base.features = "-vector".to_string(); + base.features = "-vector".into(); base.max_atomic_width = Some(64); base.min_global_align = Some(16); Target { - llvm_target: "s390x-unknown-linux-gnu".to_string(), + llvm_target: "s390x-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".to_string(), - arch: "s390x".to_string(), + data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".into(), + arch: "s390x".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs index 4f811ce98c1..4c855271a2a 100644 --- a/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs @@ -5,20 +5,20 @@ pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); base.endian = Endian::Big; // z10 is the oldest CPU supported by LLVM - base.cpu = "z10".to_string(); + base.cpu = "z10".into(); // FIXME: The data_layout string below and the ABI implementation in // cabi_s390x.rs are for now hard-coded to assume the no-vector ABI. // Pass the -vector feature string to LLVM to respect this assumption. - base.features = "-vector".to_string(); + base.features = "-vector".into(); base.max_atomic_width = Some(64); base.min_global_align = Some(16); base.static_position_independent_executables = true; Target { - llvm_target: "s390x-unknown-linux-musl".to_string(), + llvm_target: "s390x-unknown-linux-musl".into(), pointer_width: 64, - data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".to_string(), - arch: "s390x".to_string(), + data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".into(), + arch: "s390x".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs index bc32b501688..2f47abd9c7a 100644 --- a/compiler/rustc_target/src/spec/solaris_base.rs +++ b/compiler/rustc_target/src/spec/solaris_base.rs @@ -2,11 +2,11 @@ use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { TargetOptions { - os: "solaris".to_string(), + os: "solaris".into(), dynamic_linking: true, executables: true, has_rpath: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], is_like_solaris: true, linker_is_gnu: false, limit_rdylib_exports: false, // Linker doesn't support this diff --git a/compiler/rustc_target/src/spec/solid_base.rs b/compiler/rustc_target/src/spec/solid_base.rs index 421cfc40112..c5602a4513a 100644 --- a/compiler/rustc_target/src/spec/solid_base.rs +++ b/compiler/rustc_target/src/spec/solid_base.rs @@ -3,8 +3,8 @@ use crate::spec::TargetOptions; pub fn opts(kernel: &str) -> TargetOptions { TargetOptions { - os: format!("solid_{}", kernel), - vendor: "kmc".to_string(), + os: format!("solid_{}", kernel).into(), + vendor: "kmc".into(), frame_pointer: FramePointer::NonLeaf, has_thread_local: true, ..Default::default() diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs index e1aa48872b9..39efd8f305c 100644 --- a/compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs @@ -4,14 +4,14 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); base.endian = Endian::Big; - base.cpu = "v9".to_string(); + base.cpu = "v9".into(); base.max_atomic_width = Some(64); Target { - llvm_target: "sparc64-unknown-linux-gnu".to_string(), + llvm_target: "sparc64-unknown-linux-gnu".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".to_string(), - arch: "sparc64".to_string(), + data_layout: "E-m:e-i64:64-n32:64-S128".into(), + arch: "sparc64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs index b4286dfd88f..718303a4b4d 100644 --- a/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs @@ -3,15 +3,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::netbsd_base::opts(); - base.cpu = "v9".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "v9".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "sparc64-unknown-netbsd".to_string(), + llvm_target: "sparc64-unknown-netbsd".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".to_string(), - arch: "sparc64".to_string(), - options: TargetOptions { endian: Endian::Big, mcount: "__mcount".to_string(), ..base }, + data_layout: "E-m:e-i64:64-n32:64-S128".into(), + arch: "sparc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs index 9732983161f..2aaa0ca6df8 100644 --- a/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs @@ -4,15 +4,15 @@ use crate::spec::{LinkerFlavor, Target}; pub fn target() -> Target { let mut base = super::openbsd_base::opts(); base.endian = Endian::Big; - base.cpu = "v9".to_string(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.cpu = "v9".into(); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); base.max_atomic_width = Some(64); Target { - llvm_target: "sparc64-unknown-openbsd".to_string(), + llvm_target: "sparc64-unknown-openbsd".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".to_string(), - arch: "sparc64".to_string(), + data_layout: "E-m:e-i64:64-n32:64-S128".into(), + arch: "sparc64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs index 1fd4cadfffc..71d3de0bfd1 100644 --- a/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs @@ -4,15 +4,15 @@ use crate::spec::{LinkerFlavor, Target}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); base.endian = Endian::Big; - base.cpu = "v9".to_string(); + base.cpu = "v9".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mv8plus".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mv8plus".into()); Target { - llvm_target: "sparc-unknown-linux-gnu".to_string(), + llvm_target: "sparc-unknown-linux-gnu".into(), pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".to_string(), - arch: "sparc".to_string(), + data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(), + arch: "sparc".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs b/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs index abc46a8c9c3..79ae54aa666 100644 --- a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs +++ b/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs @@ -4,21 +4,21 @@ use crate::spec::{LinkerFlavor, Target}; pub fn target() -> Target { let mut base = super::solaris_base::opts(); base.endian = Endian::Big; - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".into()]); // llvm calls this "v9" - base.cpu = "v9".to_string(); - base.vendor = "sun".to_string(); + base.cpu = "v9".into(); + base.vendor = "sun".into(); base.max_atomic_width = Some(64); Target { - llvm_target: "sparcv9-sun-solaris".to_string(), + llvm_target: "sparcv9-sun-solaris".into(), pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".to_string(), + data_layout: "E-m:e-i64:64-n32:64-S128".into(), // Use "sparc64" instead of "sparcv9" here, since the former is already // used widely in the source base. If we ever needed ABI // differentiation from the sparc64, we could, but that would probably // just be confusing. - arch: "sparc64".to_string(), + arch: "sparc64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/thumb_base.rs b/compiler/rustc_target/src/spec/thumb_base.rs index e2e528561e7..ef6038e6120 100644 --- a/compiler/rustc_target/src/spec/thumb_base.rs +++ b/compiler/rustc_target/src/spec/thumb_base.rs @@ -36,7 +36,7 @@ pub fn opts() -> TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), executables: true, // In most cases, LLD is good enough - linker: Some("rust-lld".to_string()), + linker: Some("rust-lld".into()), // Because these devices have very little resources having an unwinder is too onerous so we // default to "abort" because the "unwind" strategy is very rare. panic_strategy: PanicStrategy::Abort, diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs index f86efd5d0f4..d05cb6582ba 100644 --- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs @@ -12,9 +12,9 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv4t-none-eabi".to_string(), + llvm_target: "thumbv4t-none-eabi".into(), pointer_width: 32, - arch: "arm".to_string(), + arch: "arm".into(), /* Data layout args are '-' separated: * little endian * stack is 64-bit aligned (EABI) @@ -24,24 +24,24 @@ pub fn target() -> Target { * native integers are 32-bit * All other elements are default */ - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), linker_flavor: LinkerFlavor::Ld, - linker: Some("arm-none-eabi-ld".to_string()), + linker: Some("arm-none-eabi-ld".into()), // extra args passed to the external assembler (assuming `arm-none-eabi-as`): // * activate t32/a32 interworking // * use arch ARMv4T // * use little-endian asm_args: vec![ - "-mthumb-interwork".to_string(), - "-march=armv4t".to_string(), - "-mlittle-endian".to_string(), + "-mthumb-interwork".into(), + "-march=armv4t".into(), + "-mlittle-endian".into(), ], // minimum extra features, these cannot be disabled via -C - features: "+soft-float,+strict-align".to_string(), + features: "+soft-float,+strict-align".into(), main_needs_argc_argv: false, diff --git a/compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs index 40e3281060f..2546ab9b7e6 100644 --- a/compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs @@ -4,16 +4,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv6m-none-eabi".to_string(), + llvm_target: "thumbv6m-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), // The ARMv6-M architecture doesn't support unaligned loads/stores so we disable them // with +strict-align. - features: "+strict-align".to_string(), + features: "+strict-align".into(), // There are no atomic CAS instructions available in the instruction set of the ARMv6-M // architecture atomic_cas: false, diff --git a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs index 369e6cd5e93..f6cbbd38cf4 100644 --- a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs @@ -9,20 +9,20 @@ pub fn target() -> Target { // should be smart enough to insert branch islands only // where necessary, but this is not the observed behavior. // Disabling the LBR optimization works around the issue. - let pre_link_args_msvc = "/OPT:NOLBR".to_string(); - base.pre_link_args.entry(LinkerFlavor::Msvc).or_default().push(pre_link_args_msvc.clone()); + let pre_link_args_msvc = "/OPT:NOLBR"; + base.pre_link_args.entry(LinkerFlavor::Msvc).or_default().push(pre_link_args_msvc.into()); base.pre_link_args .entry(LinkerFlavor::Lld(LldFlavor::Link)) .or_default() - .push(pre_link_args_msvc); + .push(pre_link_args_msvc.into()); Target { - llvm_target: "thumbv7a-pc-windows-msvc".to_string(), + llvm_target: "thumbv7a-pc-windows-msvc".into(), pointer_width: 32, - data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - features: "+vfp3,+neon".to_string(), + features: "+vfp3,+neon".into(), max_atomic_width: Some(64), // FIXME(jordanrh): use PanicStrategy::Unwind when SEH is // implemented for windows/arm in LLVM diff --git a/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs index 72d39ef9a95..65c2f5a704b 100644 --- a/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs @@ -2,12 +2,12 @@ use crate::spec::{PanicStrategy, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv7a-pc-windows-msvc".to_string(), + llvm_target: "thumbv7a-pc-windows-msvc".into(), pointer_width: 32, - data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - features: "+vfp3,+neon".to_string(), + features: "+vfp3,+neon".into(), max_atomic_width: Some(64), // FIXME(jordanrh): use PanicStrategy::Unwind when SEH is // implemented for windows/arm in LLVM diff --git a/compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs index 107474a86bb..000e5f2d3c6 100644 --- a/compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs @@ -13,13 +13,13 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv7em-none-eabi".to_string(), + llvm_target: "thumbv7em-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), max_atomic_width: Some(32), ..super::thumb_base::opts() }, diff --git a/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs b/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs index 65fc0db6528..39a72564e49 100644 --- a/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs @@ -12,13 +12,13 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv7em-none-eabihf".to_string(), + llvm_target: "thumbv7em-none-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // `+vfp4` is the lowest common denominator between the Cortex-M4 (vfp4-16) and the // Cortex-M7 (vfp5) // `-d32` both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers @@ -28,7 +28,7 @@ pub fn target() -> Target { // // Reference: // ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension - features: "+vfp4,-d32,-fp64".to_string(), + features: "+vfp4,-d32,-fp64".into(), max_atomic_width: Some(32), ..super::thumb_base::opts() }, diff --git a/compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs index ff939348c35..ab25cde66c7 100644 --- a/compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs @@ -4,13 +4,13 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv7m-none-eabi".to_string(), + llvm_target: "thumbv7m-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), max_atomic_width: Some(32), ..super::thumb_base::opts() }, diff --git a/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs b/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs index fcb7b5d718c..9a3e8b5c5f8 100644 --- a/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs @@ -10,15 +10,15 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::android_base::opts(); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-march=armv7-a".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-march=armv7-a".into()); Target { - llvm_target: "armv7-none-linux-android".to_string(), + llvm_target: "armv7-none-linux-android".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), - features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(), + abi: "eabi".into(), + features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), max_atomic_width: Some(64), ..base }, diff --git a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs index 9d34d9ac874..28c81340ad8 100644 --- a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs @@ -8,14 +8,14 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), + llvm_target: "armv7-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(), + features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), max_atomic_width: Some(64), ..super::linux_gnu_base::opts() }, diff --git a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs index 4e339cbd6be..2c375ab22d7 100644 --- a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs @@ -11,18 +11,18 @@ pub fn target() -> Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. - llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), + llvm_target: "armv7-unknown-linux-gnueabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), // Most of these settings are copied from the thumbv7neon_unknown_linux_gnueabihf // target. options: TargetOptions { - abi: "eabihf".to_string(), - features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(), + abi: "eabihf".into(), + features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), max_atomic_width: Some(64), - mcount: "\u{1}mcount".to_string(), + mcount: "\u{1}mcount".into(), ..super::linux_musl_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs index ef0f52d2199..756b1834c82 100644 --- a/compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs @@ -4,16 +4,16 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv8m.base-none-eabi".to_string(), + llvm_target: "thumbv8m.base-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), // ARMv8-M baseline doesn't support unaligned loads/stores so we disable them // with +strict-align. - features: "+strict-align".to_string(), + features: "+strict-align".into(), max_atomic_width: Some(32), ..super::thumb_base::opts() }, diff --git a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs index dbd184debcb..4b626854654 100644 --- a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs @@ -5,13 +5,13 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv8m.main-none-eabi".to_string(), + llvm_target: "thumbv8m.main-none-eabi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabi".to_string(), + abi: "eabi".into(), max_atomic_width: Some(32), ..super::thumb_base::opts() }, diff --git a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs b/compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs index 3caf705421c..86c25f9e4b9 100644 --- a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs @@ -5,19 +5,19 @@ use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "thumbv8m.main-none-eabihf".to_string(), + llvm_target: "thumbv8m.main-none-eabihf".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), options: TargetOptions { - abi: "eabihf".to_string(), + abi: "eabihf".into(), // If the Floating Point extension is implemented in the Cortex-M33 // processor, the Cortex-M33 Technical Reference Manual states that // the FPU uses the FPv5 architecture, single-precision instructions // and 16 D registers. // These parameters map to the following LLVM features. - features: "+fp-armv8,-fp64,-d32".to_string(), + features: "+fp-armv8,-fp64,-d32".into(), max_atomic_width: Some(32), ..super::thumb_base::opts() }, diff --git a/compiler/rustc_target/src/spec/uefi_msvc_base.rs b/compiler/rustc_target/src/spec/uefi_msvc_base.rs index 6b6b6018601..bc7244b3a45 100644 --- a/compiler/rustc_target/src/spec/uefi_msvc_base.rs +++ b/compiler/rustc_target/src/spec/uefi_msvc_base.rs @@ -18,7 +18,7 @@ pub fn opts() -> TargetOptions { // Non-standard subsystems have no default entry-point in PE+ files. We have to define // one. "efi_main" seems to be a common choice amongst other implementations and the // spec. - "/entry:efi_main".to_string(), + "/entry:efi_main".into(), // COFF images have a "Subsystem" field in their header, which defines what kind of // program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION, // EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION, @@ -28,7 +28,7 @@ pub fn opts() -> TargetOptions { // regions the application is loaded into (runtime-drivers need to be put into // reserved areas), as well as whether a return from the entry-point is treated as // exit (default for applications). - "/subsystem:efi_application".to_string(), + "/subsystem:efi_application".into(), ]; base.pre_link_args.entry(LinkerFlavor::Msvc).or_default().extend(pre_link_args_msvc.clone()); base.pre_link_args @@ -37,17 +37,17 @@ pub fn opts() -> TargetOptions { .extend(pre_link_args_msvc); TargetOptions { - os: "uefi".to_string(), + os: "uefi".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Link), disable_redzone: true, - exe_suffix: ".efi".to_string(), + exe_suffix: ".efi".into(), allows_weak_linkage: false, panic_strategy: PanicStrategy::Abort, // LLVM does not emit inline assembly because the LLVM target does not get considered as… // "Windows". stack_probes: StackProbeType::Call, singlethread: true, - linker: Some("rust-lld".to_string()), + linker: Some("rust-lld".into()), ..base } } diff --git a/compiler/rustc_target/src/spec/vxworks_base.rs b/compiler/rustc_target/src/spec/vxworks_base.rs index 3f709e70234..9808d60d891 100644 --- a/compiler/rustc_target/src/spec/vxworks_base.rs +++ b/compiler/rustc_target/src/spec/vxworks_base.rs @@ -2,21 +2,21 @@ use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { TargetOptions { - os: "vxworks".to_string(), - env: "gnu".to_string(), - vendor: "wrs".to_string(), - linker: Some("wr-c++".to_string()), - exe_suffix: ".vxe".to_string(), + os: "vxworks".into(), + env: "gnu".into(), + vendor: "wrs".into(), + linker: Some("wr-c++".into()), + exe_suffix: ".vxe".into(), dynamic_linking: true, executables: true, - families: vec!["unix".to_string()], + families: vec!["unix".into()], has_rpath: true, has_thread_local: true, crt_static_default: true, crt_static_respected: true, crt_static_allows_dylibs: true, // VxWorks needs to implement this to support profiling - mcount: "_mcount".to_string(), + mcount: "_mcount".into(), ..Default::default() } } diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs index 8fcdbc146af..89f4e6d3588 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs @@ -11,41 +11,40 @@ pub fn target() -> Target { // however it does have the side effect of automatically exporting a lot // of symbols, which approximates what people want when compiling for // wasm32-unknown-unknown expect, so use it for now. - clang_args.push("--export-dynamic".to_string()); + clang_args.push("--export-dynamic".into()); let mut post_link_args = LinkArgs::new(); post_link_args.insert( LinkerFlavor::Em, vec![ - "-s".to_string(), - "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(), - "-s".to_string(), - "ASSERTIONS=1".to_string(), - "-s".to_string(), - "ABORTING_MALLOC=0".to_string(), - "-Wl,--fatal-warnings".to_string(), + "-s".into(), + "ERROR_ON_UNDEFINED_SYMBOLS=1".into(), + "-s".into(), + "ASSERTIONS=1".into(), + "-s".into(), + "ABORTING_MALLOC=0".into(), + "-Wl,--fatal-warnings".into(), ], ); let opts = TargetOptions { - os: "emscripten".to_string(), + os: "emscripten".into(), linker_flavor: LinkerFlavor::Em, // emcc emits two files - a .js file to instantiate the wasm and supply platform // functionality, and a .wasm file. - exe_suffix: ".js".to_string(), + exe_suffix: ".js".into(), linker: None, is_like_emscripten: true, panic_strategy: PanicStrategy::Unwind, post_link_args, - families: vec!["unix".to_string(), "wasm".to_string()], + families: vec!["unix".into(), "wasm".into()], ..options }; Target { - llvm_target: "wasm32-unknown-emscripten".to_string(), + llvm_target: "wasm32-unknown-emscripten".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" - .to_string(), - arch: "wasm32".to_string(), + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), options: opts, } } diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs index e50cf974094..214b5fce5a6 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs @@ -16,7 +16,7 @@ use crate::spec::abi::Abi; pub fn target() -> Target { let mut options = wasm_base::options(); - options.os = "unknown".to_string(); + options.os = "unknown".into(); options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm); // This is a default for backwards-compatibility with the original @@ -33,29 +33,29 @@ pub fn target() -> Target { // Make sure clang uses LLD as its linker and is configured appropriately // otherwise - clang_args.push("--target=wasm32-unknown-unknown".to_string()); + clang_args.push("--target=wasm32-unknown-unknown".into()); // For now this target just never has an entry symbol no matter the output // type, so unconditionally pass this. - clang_args.push("-Wl,--no-entry".to_string()); + clang_args.push("-Wl,--no-entry".into()); // Rust really needs a way for users to specify exports and imports in // the source code. --export-dynamic isn't the right tool for this job, // however it does have the side effect of automatically exporting a lot // of symbols, which approximates what people want when compiling for // wasm32-unknown-unknown expect, so use it for now. - clang_args.push("-Wl,--export-dynamic".to_string()); + clang_args.push("-Wl,--export-dynamic".into()); // Add the flags to wasm-ld's args too. let lld_args = options.pre_link_args.entry(LinkerFlavor::Lld(LldFlavor::Wasm)).or_default(); - lld_args.push("--no-entry".to_string()); - lld_args.push("--export-dynamic".to_string()); + lld_args.push("--no-entry".into()); + lld_args.push("--export-dynamic".into()); Target { - llvm_target: "wasm32-unknown-unknown".to_string(), + llvm_target: "wasm32-unknown-unknown".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".to_string(), - arch: "wasm32".to_string(), + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), options, } } diff --git a/compiler/rustc_target/src/spec/wasm32_wasi.rs b/compiler/rustc_target/src/spec/wasm32_wasi.rs index a4b81c9a278..10eb78e4e25 100644 --- a/compiler/rustc_target/src/spec/wasm32_wasi.rs +++ b/compiler/rustc_target/src/spec/wasm32_wasi.rs @@ -78,13 +78,13 @@ use super::{crt_objects, LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut options = wasm_base::options(); - options.os = "wasi".to_string(); + options.os = "wasi".into(); options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm); options .pre_link_args .entry(LinkerFlavor::Gcc) .or_insert(Vec::new()) - .push("--target=wasm32-wasi".to_string()); + .push("--target=wasm32-wasi".into()); options.pre_link_objects_fallback = crt_objects::pre_wasi_fallback(); options.post_link_objects_fallback = crt_objects::post_wasi_fallback(); @@ -107,10 +107,10 @@ pub fn target() -> Target { options.main_needs_argc_argv = false; Target { - llvm_target: "wasm32-wasi".to_string(), + llvm_target: "wasm32-wasi".into(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".to_string(), - arch: "wasm32".to_string(), + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), options, } } diff --git a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs index 6b7dfbb87d2..609b7d42e43 100644 --- a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs @@ -12,32 +12,32 @@ use super::{LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut options = wasm_base::options(); - options.os = "unknown".to_string(); + options.os = "unknown".into(); options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm); let clang_args = options.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap(); // Make sure clang uses LLD as its linker and is configured appropriately // otherwise - clang_args.push("--target=wasm64-unknown-unknown".to_string()); + clang_args.push("--target=wasm64-unknown-unknown".into()); // For now this target just never has an entry symbol no matter the output // type, so unconditionally pass this. - clang_args.push("-Wl,--no-entry".to_string()); + clang_args.push("-Wl,--no-entry".into()); let lld_args = options.pre_link_args.get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm)).unwrap(); - lld_args.push("--no-entry".to_string()); - lld_args.push("-mwasm64".to_string()); + lld_args.push("--no-entry".into()); + lld_args.push("-mwasm64".into()); // Any engine that implements wasm64 will surely implement the rest of these // features since they were all merged into the official spec by the time // wasm64 was designed. - options.features = "+bulk-memory,+mutable-globals,+sign-ext,+nontrapping-fptoint".to_string(); + options.features = "+bulk-memory,+mutable-globals,+sign-ext,+nontrapping-fptoint".into(); Target { - llvm_target: "wasm64-unknown-unknown".to_string(), + llvm_target: "wasm64-unknown-unknown".into(), pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20".to_string(), - arch: "wasm64".to_string(), + data_layout: "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm64".into(), options, } } diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs index e1a23b213f0..e02fb1f946f 100644 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ b/compiler/rustc_target/src/spec/wasm_base.rs @@ -6,7 +6,7 @@ pub fn options() -> TargetOptions { let mut lld_args = Vec::new(); let mut clang_args = Vec::new(); let mut arg = |arg: &str| { - lld_args.push(arg.to_string()); + lld_args.push(arg.into()); clang_args.push(format!("-Wl,{}", arg)); }; @@ -61,7 +61,7 @@ pub fn options() -> TargetOptions { TargetOptions { is_like_wasm: true, - families: vec!["wasm".to_string()], + families: vec!["wasm".into()], // we allow dynamic linking, but only cdylibs. Basically we allow a // final library artifact that exports some symbols (a wasm module) but @@ -73,9 +73,9 @@ pub fn options() -> TargetOptions { executables: true, // relatively self-explanatory! - exe_suffix: ".wasm".to_string(), - dll_prefix: String::new(), - dll_suffix: ".wasm".to_string(), + exe_suffix: ".wasm".into(), + dll_prefix: "".into(), + dll_suffix: ".wasm".into(), eh_frame_header: false, max_atomic_width: Some(64), @@ -100,7 +100,7 @@ pub fn options() -> TargetOptions { limit_rdylib_exports: false, // we use the LLD shipped with the Rust toolchain by default - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), lld_flavor: LldFlavor::Wasm, linker_is_gnu: false, diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs index 35a52896f6f..d21d86caa73 100644 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs @@ -8,11 +8,11 @@ pub fn opts() -> TargetOptions { vec![ // Tell GCC to avoid linker plugins, because we are not bundling // them with Windows installer, and Rust does its own LTO anyways. - "-fno-use-linker-plugin".to_string(), + "-fno-use-linker-plugin".into(), // Enable ASLR - "-Wl,--dynamicbase".to_string(), + "-Wl,--dynamicbase".into(), // ASLR will rebase it anyway so leaving that option enabled only leads to confusion - "-Wl,--disable-auto-image-base".to_string(), + "-Wl,--disable-auto-image-base".into(), ], ); @@ -22,10 +22,10 @@ pub fn opts() -> TargetOptions { // Order of `late_link_args*` was found through trial and error to work with various // mingw-w64 versions (not tested on the CI). It's expected to change from time to time. let mingw_libs = vec![ - "-lmsvcrt".to_string(), - "-lmingwex".to_string(), - "-lmingw32".to_string(), - "-lgcc".to_string(), // alas, mingw* libraries above depend on libgcc + "-lmsvcrt".into(), + "-lmingwex".into(), + "-lmingw32".into(), + "-lgcc".into(), // alas, mingw* libraries above depend on libgcc // mingw's msvcrt is a weird hybrid import library and static library. // And it seems that the linker fails to use import symbols from msvcrt // that are required from functions in msvcrt in certain cases. For example @@ -33,9 +33,9 @@ pub fn opts() -> TargetOptions { // The library is purposely listed twice to fix that. // // See https://github.com/rust-lang/rust/pull/47483 for some more details. - "-lmsvcrt".to_string(), - "-luser32".to_string(), - "-lkernel32".to_string(), + "-lmsvcrt".into(), + "-luser32".into(), + "-lkernel32".into(), ]; late_link_args.insert(LinkerFlavor::Gcc, mingw_libs.clone()); late_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), mingw_libs); @@ -43,7 +43,7 @@ pub fn opts() -> TargetOptions { // If any of our crates are dynamically linked then we need to use // the shared libgcc_s-dw2-1.dll. This is required to support // unwinding across DLL boundaries. - "-lgcc_s".to_string(), + "-lgcc_s".into(), ]; late_link_args_dynamic.insert(LinkerFlavor::Gcc, dynamic_unwind_libs.clone()); late_link_args_dynamic.insert(LinkerFlavor::Lld(LldFlavor::Ld), dynamic_unwind_libs); @@ -53,25 +53,25 @@ pub fn opts() -> TargetOptions { // binaries to be redistributed without the libgcc_s-dw2-1.dll // dependency, but unfortunately break unwinding across DLL // boundaries when unwinding across FFI boundaries. - "-lgcc_eh".to_string(), - "-l:libpthread.a".to_string(), + "-lgcc_eh".into(), + "-l:libpthread.a".into(), ]; late_link_args_static.insert(LinkerFlavor::Gcc, static_unwind_libs.clone()); late_link_args_static.insert(LinkerFlavor::Lld(LldFlavor::Ld), static_unwind_libs); TargetOptions { - os: "windows".to_string(), - env: "gnu".to_string(), - vendor: "pc".to_string(), + os: "windows".into(), + env: "gnu".into(), + vendor: "pc".into(), // FIXME(#13846) this should be enabled for windows function_sections: false, - linker: Some("gcc".to_string()), + linker: Some("gcc".into()), dynamic_linking: true, executables: true, - dll_prefix: String::new(), - dll_suffix: ".dll".to_string(), - exe_suffix: ".exe".to_string(), - families: vec!["windows".to_string()], + dll_prefix: "".into(), + dll_suffix: ".dll".into(), + exe_suffix: ".exe".into(), + families: vec!["windows".into()], is_like_windows: true, allows_weak_linkage: false, pre_link_args, @@ -87,7 +87,6 @@ pub fn opts() -> TargetOptions { emit_debug_gdb_scripts: false, requires_uwtable: true, eh_frame_header: false, - ..Default::default() } } diff --git a/compiler/rustc_target/src/spec/windows_msvc_base.rs b/compiler/rustc_target/src/spec/windows_msvc_base.rs index 063b6538d95..a3bcaeeeb7a 100644 --- a/compiler/rustc_target/src/spec/windows_msvc_base.rs +++ b/compiler/rustc_target/src/spec/windows_msvc_base.rs @@ -4,16 +4,16 @@ pub fn opts() -> TargetOptions { let base = super::msvc_base::opts(); TargetOptions { - os: "windows".to_string(), - env: "msvc".to_string(), - vendor: "pc".to_string(), + os: "windows".into(), + env: "msvc".into(), + vendor: "pc".into(), dynamic_linking: true, - dll_prefix: String::new(), - dll_suffix: ".dll".to_string(), - exe_suffix: ".exe".to_string(), - staticlib_prefix: String::new(), - staticlib_suffix: ".lib".to_string(), - families: vec!["windows".to_string()], + dll_prefix: "".into(), + dll_suffix: ".dll".into(), + exe_suffix: ".exe".into(), + staticlib_prefix: "".into(), + staticlib_suffix: ".lib".into(), + families: vec!["windows".into()], crt_static_allows_dylibs: true, crt_static_respected: true, requires_uwtable: true, diff --git a/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs b/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs index 86df816f10d..11968391776 100644 --- a/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs @@ -9,24 +9,24 @@ pub fn opts() -> TargetOptions { let late_link_args_dynamic = LinkArgs::new(); let late_link_args_static = LinkArgs::new(); let mingw_libs = vec![ - //"-lwinstorecompat".to_string(), - //"-lmingwex".to_string(), - //"-lwinstorecompat".to_string(), - "-lwinstorecompat".to_string(), - "-lruntimeobject".to_string(), - "-lsynchronization".to_string(), - "-lvcruntime140_app".to_string(), - "-lucrt".to_string(), - "-lwindowsapp".to_string(), - "-lmingwex".to_string(), - "-lmingw32".to_string(), + //"-lwinstorecompat".into(), + //"-lmingwex".into(), + //"-lwinstorecompat".into(), + "-lwinstorecompat".into(), + "-lruntimeobject".into(), + "-lsynchronization".into(), + "-lvcruntime140_app".into(), + "-lucrt".into(), + "-lwindowsapp".into(), + "-lmingwex".into(), + "-lmingw32".into(), ]; late_link_args.insert(LinkerFlavor::Gcc, mingw_libs.clone()); late_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), mingw_libs); TargetOptions { - abi: "uwp".to_string(), - vendor: "uwp".to_string(), + abi: "uwp".into(), + vendor: "uwp".into(), executables: false, limit_rdylib_exports: false, late_link_args, diff --git a/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs b/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs index 7b56b468c28..d6b065b529a 100644 --- a/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs +++ b/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs @@ -3,9 +3,9 @@ use crate::spec::{LinkerFlavor, LldFlavor, TargetOptions}; pub fn opts() -> TargetOptions { let mut opts = super::windows_msvc_base::opts(); - opts.abi = "uwp".to_string(); - opts.vendor = "uwp".to_string(); - let pre_link_args_msvc = vec!["/APPCONTAINER".to_string(), "mincore.lib".to_string()]; + opts.abi = "uwp".into(); + opts.vendor = "uwp".into(); + let pre_link_args_msvc = vec!["/APPCONTAINER".into(), "mincore.lib".into()]; opts.pre_link_args.entry(LinkerFlavor::Msvc).or_default().extend(pre_link_args_msvc.clone()); opts.pre_link_args .entry(LinkerFlavor::Lld(LldFlavor::Link)) diff --git a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs index 22fdaabfcb8..b7b976e8d5d 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs @@ -3,13 +3,11 @@ use crate::spec::{FramePointer, LinkerFlavor, SanitizerSet, StackProbeType, Targ pub fn target() -> Target { let mut base = super::apple_base::opts("macos"); - base.cpu = "core2".to_string(); + base.cpu = "core2".into(); base.max_atomic_width = Some(128); // core2 support cmpxchg16b base.frame_pointer = FramePointer::Always; - base.pre_link_args.insert( - LinkerFlavor::Gcc, - vec!["-m64".to_string(), "-arch".to_string(), "x86_64".to_string()], - ); + base.pre_link_args + .insert(LinkerFlavor::Gcc, vec!["-m64".into(), "-arch".into(), "x86_64".into()]); base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; @@ -23,11 +21,11 @@ pub fn target() -> Target { let llvm_target = super::apple_base::macos_llvm_target(&arch); Target { - llvm_target, + llvm_target: llvm_target.into(), pointer_width: 64, data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: arch.to_string(), - options: TargetOptions { mcount: "\u{1}mcount".to_string(), ..base }, + .into(), + arch: arch.into(), + options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs b/compiler/rustc_target/src/spec/x86_64_apple_ios.rs index 6e20bd23f17..5e64ed0cff6 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_ios.rs @@ -3,12 +3,14 @@ use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { let base = opts("ios", Arch::X86_64); + let llvm_target = super::apple_base::ios_sim_llvm_target("x86_64"); + Target { - llvm_target: super::apple_base::ios_sim_llvm_target("x86_64"), + llvm_target: llvm_target.into(), pointer_width: 64, data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: TargetOptions { max_atomic_width: Some(64), // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved diff --git a/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs index c228e42ef30..c75632571ad 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs @@ -4,11 +4,11 @@ use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { let base = opts("ios", Arch::X86_64_macabi); Target { - llvm_target: "x86_64-apple-ios13.0-macabi".to_string(), + llvm_target: "x86_64-apple-ios13.0-macabi".into(), pointer_width: 64, data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: TargetOptions { max_atomic_width: Some(64), // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved diff --git a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs b/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs index e3a5de4cbd1..a848c5a0aff 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs @@ -4,10 +4,10 @@ use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { let base = opts("tvos", Arch::X86_64); Target { - llvm_target: "x86_64-apple-tvos".to_string(), + llvm_target: "x86_64-apple-tvos".into(), pointer_width: 64, - data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(), - arch: "x86_64".to_string(), + data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".into(), + arch: "x86_64".into(), options: TargetOptions { max_atomic_width: Some(64), // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs index 59cd56ebcd5..d78d057dea0 100644 --- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs @@ -1,4 +1,4 @@ -use std::iter; +use std::{borrow::Cow, iter}; use super::{LinkerFlavor, LldFlavor, Target, TargetOptions}; @@ -58,7 +58,7 @@ pub fn target() -> Target { abi: "fortanix".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), executables: true, - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), max_atomic_width: Some(64), cpu: "x86-64".into(), features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), @@ -69,7 +69,7 @@ pub fn target() -> Target { PRE_LINK_ARGS.iter().cloned().map(String::from).collect(), )) .collect(), - override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(String::from).collect()), + override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()), relax_elf_relocations: true, ..Default::default() }; diff --git a/compiler/rustc_target/src/spec/x86_64_fuchsia.rs b/compiler/rustc_target/src/spec/x86_64_fuchsia.rs index c253c0c30b3..4f88fc3500b 100644 --- a/compiler/rustc_target/src/spec/x86_64_fuchsia.rs +++ b/compiler/rustc_target/src/spec/x86_64_fuchsia.rs @@ -2,18 +2,18 @@ use crate::spec::{SanitizerSet, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::fuchsia_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI; Target { - llvm_target: "x86_64-fuchsia".to_string(), + llvm_target: "x86_64-fuchsia".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_linux_android.rs b/compiler/rustc_target/src/spec/x86_64_linux_android.rs index 657520a8caf..049cab0d554 100644 --- a/compiler/rustc_target/src/spec/x86_64_linux_android.rs +++ b/compiler/rustc_target/src/spec/x86_64_linux_android.rs @@ -2,20 +2,20 @@ use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOpti pub fn target() -> Target { let mut base = super::android_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); // https://developer.android.com/ndk/guides/abis.html#86-64 - base.features = "+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt".to_string(); + base.features = "+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "x86_64-linux-android".to_string(), + llvm_target: "x86_64-linux-android".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, } } diff --git a/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs b/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs index 6aa07286682..2a697daeb28 100644 --- a/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs +++ b/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs @@ -2,20 +2,20 @@ use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::solaris_base::opts(); - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); - base.cpu = "x86-64".to_string(); - base.vendor = "pc".to_string(); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".into()]); + base.cpu = "x86-64".into(); + base.vendor = "pc".into(); base.max_atomic_width = Some(64); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI; Target { - llvm_target: "x86_64-pc-solaris".to_string(), + llvm_target: "x86_64-pc-solaris".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs index 26a81a484b9..0fa43481c9b 100644 --- a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs @@ -2,22 +2,22 @@ use crate::spec::{LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut base = super::windows_gnu_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); let gcc_pre_link_args = base.pre_link_args.entry(LinkerFlavor::Gcc).or_default(); - gcc_pre_link_args.push("-m64".to_string()); + gcc_pre_link_args.push("-m64".into()); // Use high-entropy 64 bit address space for ASLR - gcc_pre_link_args.push("-Wl,--high-entropy-va".to_string()); + gcc_pre_link_args.push("-Wl,--high-entropy-va".into()); base.pre_link_args - .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pep".to_string()]); + .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".into(), "i386pep".into()]); base.max_atomic_width = Some(64); - base.linker = Some("x86_64-w64-mingw32-gcc".to_string()); + base.linker = Some("x86_64-w64-mingw32-gcc".into()); Target { - llvm_target: "x86_64-pc-windows-gnu".to_string(), + llvm_target: "x86_64-pc-windows-gnu".into(), pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs index 1c4ccebb488..081806aa698 100644 --- a/compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs @@ -2,15 +2,15 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::windows_msvc_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); Target { - llvm_target: "x86_64-pc-windows-msvc".to_string(), + llvm_target: "x86_64-pc-windows-msvc".into(), pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs b/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs index 2fa53470f74..a02018266fb 100644 --- a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs +++ b/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs @@ -2,19 +2,19 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::solaris_base::opts(); - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); - base.cpu = "x86-64".to_string(); - base.vendor = "sun".to_string(); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".into()]); + base.cpu = "x86-64".into(); + base.vendor = "sun".into(); base.max_atomic_width = Some(64); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "x86_64-pc-solaris".to_string(), + llvm_target: "x86_64-pc-solaris".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs b/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs index d69830f0a3f..1f2b998a7ba 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs @@ -2,18 +2,18 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::dragonfly_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "x86_64-unknown-dragonfly".to_string(), + llvm_target: "x86_64-unknown-dragonfly".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs index 24cc7ae788b..c9aedd6ea82 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs @@ -2,20 +2,20 @@ use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::freebsd_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::MEMORY | SanitizerSet::THREAD; Target { - llvm_target: "x86_64-unknown-freebsd".to_string(), + llvm_target: "x86_64-unknown-freebsd".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs b/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs index fcd96ddd61b..aebbd18c66a 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs @@ -2,20 +2,20 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::haiku_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".into()]); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; // This option is required to build executables on Haiku x86_64 base.position_independent_executables = true; Target { - llvm_target: "x86_64-unknown-haiku".to_string(), + llvm_target: "x86_64-unknown-haiku".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs b/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs index 1ef24b6eb36..d315301615b 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs @@ -2,18 +2,18 @@ use crate::spec::{StackProbeType, Target}; pub fn target() -> Target { let mut base = super::hermit_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.features = "+rdrnd,+rdseed".to_string(); + base.features = "+rdrnd,+rdseed".into(); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "x86_64-unknown-hermit".to_string(), + llvm_target: "x86_64-unknown-hermit".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs b/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs index 79ccf63acfa..9529fa9640d 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs @@ -2,19 +2,19 @@ use crate::spec::{LinkerFlavor, SanitizerSet, Target}; pub fn target() -> Target { let mut base = super::illumos_base::opts(); - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string(), "-std=c99".to_string()]); - base.cpu = "x86-64".to_string(); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".into(), "-std=c99".into()]); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI; Target { // LLVM does not currently have a separate illumos target, // so we still pass Solaris to it - llvm_target: "x86_64-pc-solaris".to_string(), + llvm_target: "x86_64-pc-solaris".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs b/compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs index 64c7c1c5f6f..78189a0c096 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs @@ -2,18 +2,18 @@ use crate::spec::{PanicStrategy, Target}; pub fn target() -> Target { let mut base = super::l4re_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); base.crt_static_allows_dylibs = false; base.dynamic_linking = false; base.panic_strategy = PanicStrategy::Abort; Target { - llvm_target: "x86_64-unknown-l4re-uclibc".to_string(), + llvm_target: "x86_64-unknown-l4re-uclibc".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs index aefbb398286..e525cfdde14 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs @@ -2,9 +2,9 @@ use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.static_position_independent_executables = true; @@ -15,11 +15,11 @@ pub fn target() -> Target { | SanitizerSet::THREAD; Target { - llvm_target: "x86_64-unknown-linux-gnu".to_string(), + llvm_target: "x86_64-unknown-linux-gnu".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs index 109f86d3a41..863b41633e2 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs @@ -2,10 +2,10 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); - base.cpu = "x86-64".to_string(); - base.abi = "x32".to_string(); + base.cpu = "x86-64".into(); + base.abi = "x32".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mx32".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mx32".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.has_thread_local = false; @@ -14,12 +14,12 @@ pub fn target() -> Target { base.needs_plt = true; Target { - llvm_target: "x86_64-unknown-linux-gnux32".to_string(), + llvm_target: "x86_64-unknown-linux-gnux32".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs index a5e79803335..8678f06e2cb 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs @@ -2,9 +2,9 @@ use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.static_position_independent_executables = true; @@ -15,11 +15,11 @@ pub fn target() -> Target { | SanitizerSet::THREAD; Target { - llvm_target: "x86_64-unknown-linux-musl".to_string(), + llvm_target: "x86_64-unknown-linux-musl".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs index bdb2be4f863..a7115dace1c 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs @@ -2,9 +2,9 @@ use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOpti pub fn target() -> Target { let mut base = super::netbsd_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = SanitizerSet::ADDRESS @@ -14,11 +14,11 @@ pub fn target() -> Target { | SanitizerSet::THREAD; Target { - llvm_target: "x86_64-unknown-netbsd".to_string(), + llvm_target: "x86_64-unknown-netbsd".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), - options: TargetOptions { mcount: "__mcount".to_string(), ..base }, + .into(), + arch: "x86_64".into(), + options: TargetOptions { mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_none.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none.rs index 722409dd168..0c510dfaa12 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_none.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_none.rs @@ -11,7 +11,7 @@ use super::{ pub fn target() -> Target { let opts = TargetOptions { - cpu: "x86-64".to_string(), + cpu: "x86-64".into(), max_atomic_width: Some(64), // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved stack_probes: StackProbeType::Call, @@ -20,10 +20,10 @@ pub fn target() -> Target { relro_level: RelroLevel::Full, relocation_model: RelocModel::Pic, linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - linker: Some("rust-lld".to_owned()), + linker: Some("rust-lld".into()), features: "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float" - .to_string(), + .into(), executables: true, disable_redzone: true, panic_strategy: PanicStrategy::Abort, @@ -31,11 +31,11 @@ pub fn target() -> Target { ..Default::default() }; Target { - llvm_target: "x86_64-unknown-none-elf".to_string(), + llvm_target: "x86_64-unknown-none-elf".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: opts, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs index fa6f255d4d9..0db88d64ac0 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_none_linuxkernel.rs @@ -5,24 +5,23 @@ use crate::spec::{CodeModel, LinkerFlavor, Target}; pub fn target() -> Target { let mut base = super::linux_kernel_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); base.features = - "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float" - .to_string(); + "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float".into(); base.code_model = Some(CodeModel::Kernel); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); Target { // FIXME: Some dispute, the linux-on-clang folks think this should use // "Linux". We disagree because running *on* Linux is nothing like // running *as" linux, and historically the "os" component as has always // been used to mean the "on" part. - llvm_target: "x86_64-unknown-none-elf".to_string(), + llvm_target: "x86_64-unknown-none-elf".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs index 4eb3f34a036..11e9cc4abc0 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs @@ -2,18 +2,18 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::openbsd_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "x86_64-unknown-openbsd".to_string(), + llvm_target: "x86_64-unknown-openbsd".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs b/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs index b8269ecae20..af8b9673c30 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs @@ -2,18 +2,18 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::redox_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; Target { - llvm_target: "x86_64-unknown-redox".to_string(), + llvm_target: "x86_64-unknown-redox".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs b/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs index be0e62bea02..a7ae17839da 100644 --- a/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs @@ -9,7 +9,7 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::uefi_msvc_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); // We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to @@ -22,14 +22,14 @@ pub fn target() -> Target { // // If you initialize FP units yourself, you can override these flags with custom linker // arguments, thus giving you access to full MMX/SSE acceleration. - base.features = "-mmx,-sse,+soft-float".to_string(); + base.features = "-mmx,-sse,+soft-float".into(); Target { - llvm_target: "x86_64-unknown-windows".to_string(), + llvm_target: "x86_64-unknown-windows".into(), pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } diff --git a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs index a5425e1c129..a94bbbf6ede 100644 --- a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs @@ -2,21 +2,21 @@ use crate::spec::{LinkerFlavor, LldFlavor, Target}; pub fn target() -> Target { let mut base = super::windows_uwp_gnu_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); let gcc_pre_link_args = base.pre_link_args.entry(LinkerFlavor::Gcc).or_default(); - gcc_pre_link_args.push("-m64".to_string()); + gcc_pre_link_args.push("-m64".into()); // Use high-entropy 64 bit address space for ASLR - gcc_pre_link_args.push("-Wl,--high-entropy-va".to_string()); + gcc_pre_link_args.push("-Wl,--high-entropy-va".into()); base.pre_link_args - .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pep".to_string()]); + .insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".into(), "i386pep".into()]); base.max_atomic_width = Some(64); Target { - llvm_target: "x86_64-pc-windows-gnu".to_string(), + llvm_target: "x86_64-pc-windows-gnu".into(), pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs index 06ccc272300..b2769350bf6 100644 --- a/compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs @@ -2,15 +2,15 @@ use crate::spec::Target; pub fn target() -> Target { let mut base = super::windows_uwp_msvc_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); Target { - llvm_target: "x86_64-pc-windows-msvc".to_string(), + llvm_target: "x86_64-pc-windows-msvc".into(), pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } diff --git a/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs index f9f775084fb..16d29753e7d 100644 --- a/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs @@ -2,19 +2,19 @@ use crate::spec::{LinkerFlavor, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::vxworks_base::opts(); - base.cpu = "x86-64".to_string(); + base.cpu = "x86-64".into(); base.max_atomic_width = Some(64); - base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string()); + base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.disable_redzone = true; Target { - llvm_target: "x86_64-unknown-linux-gnu".to_string(), + llvm_target: "x86_64-unknown-linux-gnu".into(), pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), + .into(), + arch: "x86_64".into(), options: base, } } From ce61d4044d7621fd190a2ddd1f51fa78e2941518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BRANSTETT?= Date: Mon, 28 Mar 2022 01:08:17 +0200 Subject: [PATCH 07/10] Replace every Vec in Target(Options) with it's Cow equivalent --- compiler/rustc_codegen_ssa/src/back/link.rs | 4 +- compiler/rustc_serialize/src/json.rs | 9 ++++ compiler/rustc_session/src/config.rs | 2 +- .../src/spec/aarch64_apple_darwin.rs | 2 +- compiler/rustc_target/src/spec/apple_base.rs | 6 ++- .../rustc_target/src/spec/apple_sdk_base.rs | 8 ++-- .../src/spec/armv6k_nintendo_3ds.rs | 4 +- .../rustc_target/src/spec/dragonfly_base.rs | 4 +- .../rustc_target/src/spec/freebsd_base.rs | 4 +- .../rustc_target/src/spec/fuchsia_base.rs | 4 +- compiler/rustc_target/src/spec/haiku_base.rs | 4 +- .../src/spec/i686_apple_darwin.rs | 2 +- .../rustc_target/src/spec/illumos_base.rs | 4 +- compiler/rustc_target/src/spec/l4re_base.rs | 4 +- compiler/rustc_target/src/spec/linux_base.rs | 4 +- .../rustc_target/src/spec/mipsel_sony_psp.rs | 4 +- compiler/rustc_target/src/spec/mod.rs | 45 +++++++++++++------ .../rustc_target/src/spec/msp430_none_elf.rs | 3 +- compiler/rustc_target/src/spec/netbsd_base.rs | 4 +- .../rustc_target/src/spec/openbsd_base.rs | 4 +- compiler/rustc_target/src/spec/redox_base.rs | 4 +- .../src/spec/riscv32imc_esp_espidf.rs | 4 +- .../rustc_target/src/spec/solaris_base.rs | 4 +- .../src/spec/thumbv4t_none_eabi.rs | 7 +-- .../rustc_target/src/spec/vxworks_base.rs | 4 +- .../src/spec/wasm32_unknown_emscripten.rs | 4 +- compiler/rustc_target/src/spec/wasm_base.rs | 4 +- .../rustc_target/src/spec/windows_gnu_base.rs | 4 +- .../src/spec/windows_msvc_base.rs | 4 +- .../src/spec/x86_64_apple_darwin.rs | 2 +- .../src/spec/x86_64_fortanix_unknown_sgx.rs | 4 +- 31 files changed, 117 insertions(+), 53 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 8b31d24b071..07edb70634e 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -674,10 +674,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( linker::disable_localization(&mut cmd); - for &(ref k, ref v) in &sess.target.link_env { + for &(ref k, ref v) in sess.target.link_env.iter() { cmd.env(k.as_ref(), v.as_ref()); } - for k in &sess.target.link_env_remove { + for k in sess.target.link_env_remove.iter() { cmd.env_remove(k.as_ref()); } diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs index 9847fde3c49..c915dd5bbf6 100644 --- a/compiler/rustc_serialize/src/json.rs +++ b/compiler/rustc_serialize/src/json.rs @@ -2247,6 +2247,15 @@ impl ToJson for Vec { } } +impl<'a, A: ToJson> ToJson for Cow<'a, [A]> +where + [A]: ToOwned, +{ + fn to_json(&self) -> Json { + Json::Array(self.iter().map(|elt| elt.to_json()).collect()) + } +} + impl ToJson for BTreeMap { fn to_json(&self) -> Json { let mut d = BTreeMap::new(); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 856436e44db..408fd4ed2e6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -956,7 +956,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { ret.reserve(7); // the minimum number of insertions // Target bindings. ret.insert((sym::target_os, Some(Symbol::intern(os)))); - for fam in &sess.target.families { + for fam in sess.target.families.iter() { ret.insert((sym::target_family, Some(Symbol::intern(fam)))); if fam == "windows" { ret.insert((sym::windows, None)); diff --git a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs index ef9e6bbea4d..86f76fdb6a7 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs @@ -9,7 +9,7 @@ pub fn target() -> Target { base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".into(), "arm64".into()]); - base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); + base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove()); // Clang automatically chooses a more specific target based on // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index 748989b2a6f..f2cef7996ff 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -2,6 +2,8 @@ use std::{borrow::Cow, env}; use crate::spec::{FramePointer, LldFlavor, SplitDebuginfo, TargetOptions}; +use super::cvs; + pub fn opts(os: &'static str) -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 // either the linker will complain if it is used or the binary will end up @@ -26,7 +28,7 @@ pub fn opts(os: &'static str) -> TargetOptions { dynamic_linking: true, linker_is_gnu: false, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_osx: true, dwarf_version: Some(2), frame_pointer: FramePointer::Always, @@ -51,7 +53,7 @@ pub fn opts(os: &'static str) -> TargetOptions { // this environment variable too in recent versions. // // For some more info see the commentary on #47086 - link_env: vec![("ZERO_AR_DATE".into(), "1".into())], + link_env: Cow::Borrowed(&[(Cow::Borrowed("ZERO_AR_DATE"), Cow::Borrowed("1"))]), ..Default::default() } diff --git a/compiler/rustc_target/src/spec/apple_sdk_base.rs b/compiler/rustc_target/src/spec/apple_sdk_base.rs index 3ab9dbe07a3..e2d08955c08 100644 --- a/compiler/rustc_target/src/spec/apple_sdk_base.rs +++ b/compiler/rustc_target/src/spec/apple_sdk_base.rs @@ -1,4 +1,4 @@ -use crate::spec::TargetOptions; +use crate::{spec::cvs, spec::TargetOptions}; use std::borrow::Cow; use Arch::*; @@ -36,12 +36,12 @@ fn target_cpu(arch: Arch) -> &'static str { } } -fn link_env_remove(arch: Arch) -> Vec> { +fn link_env_remove(arch: Arch) -> Cow<'static, [Cow<'static, str>]> { match arch { Armv7 | Armv7s | Arm64 | I386 | X86_64 | Arm64_sim => { - vec!["MACOSX_DEPLOYMENT_TARGET".into()] + cvs!["MACOSX_DEPLOYMENT_TARGET"] } - X86_64_macabi | Arm64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".into()], + X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"], } } diff --git a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs index 93897dd4938..2e050b44156 100644 --- a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs +++ b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs @@ -1,5 +1,7 @@ use crate::spec::{LinkArgs, LinkerFlavor, RelocModel, Target, TargetOptions}; +use super::cvs; + /// A base target for Nintendo 3DS devices using the devkitARM toolchain. /// /// Requires the devkitARM toolchain for 3DS targets on the host system. @@ -30,7 +32,7 @@ pub fn target() -> Target { linker_flavor: LinkerFlavor::Gcc, cpu: "mpcore".into(), executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], linker: Some("arm-none-eabi-gcc".into()), relocation_model: RelocModel::Static, features: "+vfp2".into(), diff --git a/compiler/rustc_target/src/spec/dragonfly_base.rs b/compiler/rustc_target/src/spec/dragonfly_base.rs index 03e4b953184..43072d63894 100644 --- a/compiler/rustc_target/src/spec/dragonfly_base.rs +++ b/compiler/rustc_target/src/spec/dragonfly_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "dragonfly".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/freebsd_base.rs b/compiler/rustc_target/src/spec/freebsd_base.rs index 0153b4dd80f..05d60574f32 100644 --- a/compiler/rustc_target/src/spec/freebsd_base.rs +++ b/compiler/rustc_target/src/spec/freebsd_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "freebsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index e802cdcf489..2ee7047d7e0 100644 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ b/compiler/rustc_target/src/spec/fuchsia_base.rs @@ -1,5 +1,7 @@ use crate::spec::{crt_objects, LinkArgs, LinkOutputKind, LinkerFlavor, LldFlavor, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); pre_link_args.insert( @@ -25,7 +27,7 @@ pub fn opts() -> TargetOptions { linker: Some("rust-lld".into()), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_fuchsia: true, pre_link_args, pre_link_objects: crt_objects::new(&[ diff --git a/compiler/rustc_target/src/spec/haiku_base.rs b/compiler/rustc_target/src/spec/haiku_base.rs index 3585604a640..25549491f4b 100644 --- a/compiler/rustc_target/src/spec/haiku_base.rs +++ b/compiler/rustc_target/src/spec/haiku_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "haiku".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], relro_level: RelroLevel::Full, ..Default::default() } diff --git a/compiler/rustc_target/src/spec/i686_apple_darwin.rs b/compiler/rustc_target/src/spec/i686_apple_darwin.rs index a083a83e377..ad716a6cd5a 100644 --- a/compiler/rustc_target/src/spec/i686_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/i686_apple_darwin.rs @@ -5,7 +5,7 @@ pub fn target() -> Target { base.cpu = "yonah".into(); base.max_atomic_width = Some(64); base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".into()]); - base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); + base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.frame_pointer = FramePointer::Always; diff --git a/compiler/rustc_target/src/spec/illumos_base.rs b/compiler/rustc_target/src/spec/illumos_base.rs index 68917171105..1f6202dd7f5 100644 --- a/compiler/rustc_target/src/spec/illumos_base.rs +++ b/compiler/rustc_target/src/spec/illumos_base.rs @@ -1,6 +1,8 @@ use crate::spec::{FramePointer, LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; +use super::cvs; + pub fn opts() -> TargetOptions { let mut late_link_args = LinkArgs::new(); late_link_args.insert( @@ -31,7 +33,7 @@ pub fn opts() -> TargetOptions { dynamic_linking: true, executables: true, has_rpath: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_solaris: true, linker_is_gnu: false, limit_rdylib_exports: false, // Linker doesn't support this diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs index dbc851cc1e1..e185de78bca 100644 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ b/compiler/rustc_target/src/spec/l4re_base.rs @@ -1,6 +1,8 @@ use crate::spec::{LinkerFlavor, PanicStrategy, TargetOptions}; use std::default::Default; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "l4re".into(), @@ -10,7 +12,7 @@ pub fn opts() -> TargetOptions { panic_strategy: PanicStrategy::Abort, linker: Some("l4-bender".into()), linker_is_gnu: false, - families: vec!["unix".into()], + families: cvs!["unix"], ..Default::default() } } diff --git a/compiler/rustc_target/src/spec/linux_base.rs b/compiler/rustc_target/src/spec/linux_base.rs index 135ca547d1d..84d8e19159a 100644 --- a/compiler/rustc_target/src/spec/linux_base.rs +++ b/compiler/rustc_target/src/spec/linux_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "linux".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs index 6857f7fd17d..dc8169b7118 100644 --- a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs +++ b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs @@ -1,6 +1,8 @@ use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, RelocModel}; use crate::spec::{Target, TargetOptions}; +use super::cvs; + // The PSP has custom linker requirements. const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); @@ -27,7 +29,7 @@ pub fn target() -> Target { features: "+single-float".into(), // PSP does not support trap-on-condition instructions. - llvm_args: vec!["-mno-check-zero-division".into()], + llvm_args: cvs!["-mno-check-zero-division"], pre_link_args, link_script: Some(LINKER_SCRIPT.into()), ..Default::default() diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 0c5bddad72a..6d23ddc0985 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1027,6 +1027,25 @@ supported_targets! { ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), } +/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> +// FIXME(Urgau): Figure out why the obvious form `["".into()].into()` doesn't work. +macro_rules! cvs { + () => { + ::std::borrow::Cow::Borrowed(&[]) + }; + ($($x:expr),+ $(,)?) => { + { + ::std::borrow::Cow::Borrowed(&[ + $( + ::std::borrow::Cow::Borrowed($x), + )* + ]) + } + }; +} + +pub(crate) use cvs; + /// Warnings encountered when parsing the target `json`. /// /// Includes fields that weren't recognized and fields that don't have the expected type. @@ -1160,12 +1179,12 @@ pub struct TargetOptions { pub link_script: Option>, /// Environment variables to be set for the linker invocation. - pub link_env: Vec<(Cow<'static, str>, Cow<'static, str>)>, + pub link_env: Cow<'static, [(Cow<'static, str>, Cow<'static, str>)]>, /// Environment variables to be removed for the linker invocation. - pub link_env_remove: Vec>, + pub link_env_remove: Cow<'static, [Cow<'static, str>]>, /// Extra arguments to pass to the external assembler (when used) - pub asm_args: Vec>, + pub asm_args: Cow<'static, [Cow<'static, str>]>, /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults /// to "generic". @@ -1211,7 +1230,7 @@ pub struct TargetOptions { /// Common options are: "unix", "windows". Defaults to no families. /// /// See . - pub families: Vec>, + pub families: Cow<'static, [Cow<'static, str>]>, /// Whether the target toolchain's ABI supports returning small structs as an integer. pub abi_return_struct_as_int: bool, /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS, @@ -1371,7 +1390,7 @@ pub struct TargetOptions { /// If set, have the linker export exactly these symbols, instead of using /// the usual logic to figure this out from the crate itself. - pub override_export_symbols: Option>>, + pub override_export_symbols: Option]>>, /// Determines how or whether the MergeFunctions LLVM pass should run for /// this target. Either "disabled", "trampolines", or "aliases". @@ -1391,7 +1410,7 @@ pub struct TargetOptions { pub relax_elf_relocations: bool, /// Additional arguments to pass to LLVM, similar to the `-C llvm-args` codegen option. - pub llvm_args: Vec>, + pub llvm_args: Cow<'static, [Cow<'static, str>]>, /// Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults /// to false (uses .init_array). @@ -1449,7 +1468,7 @@ impl Default for TargetOptions { pre_link_args: LinkArgs::new(), post_link_args: LinkArgs::new(), link_script: None, - asm_args: Vec::new(), + asm_args: Cow::Borrowed(&[]), cpu: "generic".into(), features: Cow::from(""), dynamic_linking: false, @@ -1466,7 +1485,7 @@ impl Default for TargetOptions { exe_suffix: Cow::from(""), staticlib_prefix: "lib".into(), staticlib_suffix: ".a".into(), - families: Vec::new(), + families: cvs![], abi_return_struct_as_int: false, is_like_osx: false, is_like_solaris: false, @@ -1492,8 +1511,8 @@ impl Default for TargetOptions { late_link_args: LinkArgs::new(), late_link_args_dynamic: LinkArgs::new(), late_link_args_static: LinkArgs::new(), - link_env: Vec::new(), - link_env_remove: Vec::new(), + link_env: Cow::Borrowed(&[]), + link_env_remove: Cow::Borrowed(&[]), archive_format: "gnu".into(), main_needs_argc_argv: true, allow_asm: true, @@ -1526,7 +1545,7 @@ impl Default for TargetOptions { mcount: "mcount".into(), llvm_abiname: "".into(), relax_elf_relocations: false, - llvm_args: vec![], + llvm_args: cvs![], use_ctors_section: false, eh_frame_header: true, has_thumb_interworking: false, @@ -1978,7 +1997,7 @@ impl Target { if p.len() == 2 { let k = p[0].to_string(); let v = p[1].to_string(); - base.$key_name.push((k.into(), v.into())); + base.$key_name.to_mut().push((k.into(), v.into())); } } } @@ -2004,7 +2023,7 @@ impl Target { .map(|a| a.as_string().unwrap().to_string().into()) .collect(); } else if let Some(v) = Json::as_string(&value) { - base.$key_name = vec![v.to_string().into()]; + base.$key_name = vec![v.to_string().into()].into(); } } } ); diff --git a/compiler/rustc_target/src/spec/msp430_none_elf.rs b/compiler/rustc_target/src/spec/msp430_none_elf.rs index 2dd23b7d3c3..f22c8672639 100644 --- a/compiler/rustc_target/src/spec/msp430_none_elf.rs +++ b/compiler/rustc_target/src/spec/msp430_none_elf.rs @@ -1,3 +1,4 @@ +use super::cvs; use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions}; pub fn target() -> Target { @@ -15,7 +16,7 @@ pub fn target() -> Target { // workaround this LLVM generates assembly files which then we feed // to gcc to get object files. For this reason we have a hard // dependency on this specific gcc. - asm_args: vec!["-mcpu=msp430".into()], + asm_args: cvs!["-mcpu=msp430"], linker: Some("msp430-elf-gcc".into()), linker_is_gnu: false, diff --git a/compiler/rustc_target/src/spec/netbsd_base.rs b/compiler/rustc_target/src/spec/netbsd_base.rs index c20eb163dda..a5fb58f5e7b 100644 --- a/compiler/rustc_target/src/spec/netbsd_base.rs +++ b/compiler/rustc_target/src/spec/netbsd_base.rs @@ -1,11 +1,13 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "netbsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], no_default_libraries: false, has_rpath: true, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/openbsd_base.rs b/compiler/rustc_target/src/spec/openbsd_base.rs index a913be93861..7745d10e13e 100644 --- a/compiler/rustc_target/src/spec/openbsd_base.rs +++ b/compiler/rustc_target/src/spec/openbsd_base.rs @@ -1,11 +1,13 @@ use crate::spec::{FramePointer, RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "openbsd".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, abi_return_struct_as_int: true, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/redox_base.rs b/compiler/rustc_target/src/spec/redox_base.rs index 51774059c10..667aa8e9c94 100644 --- a/compiler/rustc_target/src/spec/redox_base.rs +++ b/compiler/rustc_target/src/spec/redox_base.rs @@ -1,12 +1,14 @@ use crate::spec::{RelroLevel, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "redox".into(), env: "relibc".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, diff --git a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs index d9f40d51069..4c7401380fd 100644 --- a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs @@ -1,6 +1,8 @@ use crate::spec::{LinkerFlavor, PanicStrategy, RelocModel}; use crate::spec::{Target, TargetOptions}; +use super::cvs; + pub fn target() -> Target { Target { data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), @@ -9,7 +11,7 @@ pub fn target() -> Target { arch: "riscv32".into(), options: TargetOptions { - families: vec!["unix".into()], + families: cvs!["unix"], os: "espidf".into(), env: "newlib".into(), vendor: "espressif".into(), diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs index 2f47abd9c7a..8d8ad049b33 100644 --- a/compiler/rustc_target/src/spec/solaris_base.rs +++ b/compiler/rustc_target/src/spec/solaris_base.rs @@ -1,12 +1,14 @@ use crate::spec::TargetOptions; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "solaris".into(), dynamic_linking: true, executables: true, has_rpath: true, - families: vec!["unix".into()], + families: cvs!["unix"], is_like_solaris: true, linker_is_gnu: false, limit_rdylib_exports: false, // Linker doesn't support this diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs index d05cb6582ba..457b78850ac 100644 --- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs @@ -8,6 +8,7 @@ //! //! **Important:** This target profile **does not** specify a linker script. You just get the default link script when you build a binary for this target. The default link script is very likely wrong, so you should use `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. +use super::cvs; use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { @@ -34,11 +35,7 @@ pub fn target() -> Target { // * activate t32/a32 interworking // * use arch ARMv4T // * use little-endian - asm_args: vec![ - "-mthumb-interwork".into(), - "-march=armv4t".into(), - "-mlittle-endian".into(), - ], + asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",], // minimum extra features, these cannot be disabled via -C features: "+soft-float,+strict-align".into(), diff --git a/compiler/rustc_target/src/spec/vxworks_base.rs b/compiler/rustc_target/src/spec/vxworks_base.rs index 9808d60d891..f43cea131b7 100644 --- a/compiler/rustc_target/src/spec/vxworks_base.rs +++ b/compiler/rustc_target/src/spec/vxworks_base.rs @@ -1,5 +1,7 @@ use crate::spec::TargetOptions; +use super::cvs; + pub fn opts() -> TargetOptions { TargetOptions { os: "vxworks".into(), @@ -9,7 +11,7 @@ pub fn opts() -> TargetOptions { exe_suffix: ".vxe".into(), dynamic_linking: true, executables: true, - families: vec!["unix".into()], + families: cvs!["unix"], has_rpath: true, has_thread_local: true, crt_static_default: true, diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs index 89f4e6d3588..b34cac41d78 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs @@ -1,4 +1,4 @@ -use super::wasm_base; +use super::{cvs, wasm_base}; use super::{LinkArgs, LinkerFlavor, PanicStrategy, Target, TargetOptions}; pub fn target() -> Target { @@ -37,7 +37,7 @@ pub fn target() -> Target { is_like_emscripten: true, panic_strategy: PanicStrategy::Unwind, post_link_args, - families: vec!["unix".into(), "wasm".into()], + families: cvs!["unix", "wasm"], ..options }; Target { diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs index e02fb1f946f..d884dcf68bf 100644 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ b/compiler/rustc_target/src/spec/wasm_base.rs @@ -1,5 +1,5 @@ use super::crt_objects::CrtObjectsFallback; -use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel}; +use super::{cvs, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel}; use std::collections::BTreeMap; pub fn options() -> TargetOptions { @@ -61,7 +61,7 @@ pub fn options() -> TargetOptions { TargetOptions { is_like_wasm: true, - families: vec!["wasm".into()], + families: cvs!["wasm"], // we allow dynamic linking, but only cdylibs. Basically we allow a // final library artifact that exports some symbols (a wasm module) but diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs index d21d86caa73..1e5ced684bd 100644 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs @@ -1,6 +1,8 @@ use crate::spec::crt_objects::{self, CrtObjectsFallback}; use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, TargetOptions}; +use super::cvs; + pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); pre_link_args.insert( @@ -71,7 +73,7 @@ pub fn opts() -> TargetOptions { dll_prefix: "".into(), dll_suffix: ".dll".into(), exe_suffix: ".exe".into(), - families: vec!["windows".into()], + families: cvs!["windows"], is_like_windows: true, allows_weak_linkage: false, pre_link_args, diff --git a/compiler/rustc_target/src/spec/windows_msvc_base.rs b/compiler/rustc_target/src/spec/windows_msvc_base.rs index a3bcaeeeb7a..bfe8edecac4 100644 --- a/compiler/rustc_target/src/spec/windows_msvc_base.rs +++ b/compiler/rustc_target/src/spec/windows_msvc_base.rs @@ -1,5 +1,7 @@ use crate::spec::TargetOptions; +use super::cvs; + pub fn opts() -> TargetOptions { let base = super::msvc_base::opts(); @@ -13,7 +15,7 @@ pub fn opts() -> TargetOptions { exe_suffix: ".exe".into(), staticlib_prefix: "".into(), staticlib_suffix: ".lib".into(), - families: vec!["windows".into()], + families: cvs!["windows"], crt_static_allows_dylibs: true, crt_static_respected: true, requires_uwtable: true, diff --git a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs index b7b976e8d5d..51d14f0403a 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs @@ -8,7 +8,7 @@ pub fn target() -> Target { base.frame_pointer = FramePointer::Always; base.pre_link_args .insert(LinkerFlavor::Gcc, vec!["-m64".into(), "-arch".into(), "x86_64".into()]); - base.link_env_remove.extend(super::apple_base::macos_link_env_remove()); + base.link_env_remove.to_mut().extend(super::apple_base::macos_link_env_remove()); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs index d78d057dea0..33b5917b401 100644 --- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs @@ -1,5 +1,7 @@ use std::{borrow::Cow, iter}; +use crate::spec::cvs; + use super::{LinkerFlavor, LldFlavor, Target, TargetOptions}; pub fn target() -> Target { @@ -62,7 +64,7 @@ pub fn target() -> Target { max_atomic_width: Some(64), cpu: "x86-64".into(), features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), - llvm_args: vec!["--x86-experimental-lvi-inline-asm-hardening".into()], + llvm_args: cvs!["--x86-experimental-lvi-inline-asm-hardening"], position_independent_executables: true, pre_link_args: iter::once(( LinkerFlavor::Lld(LldFlavor::Ld), From c16a558f245cdf363ede29bed0d682434885f826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BRANSTETT?= Date: Mon, 28 Mar 2022 15:06:46 +0200 Subject: [PATCH 08/10] Replace LinkArgs with Cow<'static, str> --- compiler/rustc_codegen_ssa/src/back/link.rs | 11 ++++++----- compiler/rustc_target/src/spec/avr_gnu_base.rs | 2 +- compiler/rustc_target/src/spec/mod.rs | 4 ++-- compiler/rustc_target/src/spec/wasm_base.rs | 4 ++-- .../src/spec/x86_64_fortanix_unknown_sgx.rs | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 07edb70634e..40fe3c86e43 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -40,6 +40,7 @@ use std::ffi::OsString; use std::fs::{File, OpenOptions}; use std::io::{BufWriter, Write}; use std::lazy::OnceCell; +use std::ops::Deref; use std::path::{Path, PathBuf}; use std::process::{ExitStatus, Output, Stdio}; use std::{ascii, char, env, fmt, fs, io, mem, str}; @@ -1586,7 +1587,7 @@ fn add_post_link_objects( /// FIXME: Determine where exactly these args need to be inserted. fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { if let Some(args) = sess.target.pre_link_args.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } cmd.args(&sess.opts.debugging_opts.pre_link_args); } @@ -1634,15 +1635,15 @@ fn add_late_link_args( }); if any_dynamic_crate { if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } else { if let Some(args) = sess.target.late_link_args_static.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } if let Some(args) = sess.target.late_link_args.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } @@ -1650,7 +1651,7 @@ fn add_late_link_args( /// FIXME: Determine where exactly these args need to be inserted. fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { if let Some(args) = sess.target.post_link_args.get(&flavor) { - cmd.args(args); + cmd.args(args.iter().map(Deref::deref)); } } diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs index 9d4ec2edc51..c288e8b0e9e 100644 --- a/compiler/rustc_target/src/spec/avr_gnu_base.rs +++ b/compiler/rustc_target/src/spec/avr_gnu_base.rs @@ -17,7 +17,7 @@ pub fn target(target_cpu: &'static str) -> Target { linker: Some("avr-gcc".into()), executables: true, eh_frame_header: false, - pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])] + pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu).into()])] .into_iter() .collect(), late_link_args: [(LinkerFlavor::Gcc, vec!["-lgcc".into()])].into_iter().collect(), diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 6d23ddc0985..96623e1c163 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -459,7 +459,7 @@ impl fmt::Display for LinkOutputKind { } } -pub type LinkArgs = BTreeMap>; +pub type LinkArgs = BTreeMap>>; #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)] pub enum SplitDebuginfo { @@ -1978,7 +1978,7 @@ impl Target { .map(|(i,s)| { let s = s.as_string().ok_or_else(|| format!("{}.{}[{}]: expected a JSON string", name, k, i))?; - Ok(s.into()) + Ok(s.to_string().into()) }) .collect::, String>>()?; diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs index d884dcf68bf..de7b7374af3 100644 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ b/compiler/rustc_target/src/spec/wasm_base.rs @@ -5,9 +5,9 @@ use std::collections::BTreeMap; pub fn options() -> TargetOptions { let mut lld_args = Vec::new(); let mut clang_args = Vec::new(); - let mut arg = |arg: &str| { + let mut arg = |arg: &'static str| { lld_args.push(arg.into()); - clang_args.push(format!("-Wl,{}", arg)); + clang_args.push(format!("-Wl,{}", arg).into()); }; // By default LLD only gives us one page of stack (64k) which is a diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs index 33b5917b401..47c70513faf 100644 --- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs @@ -68,7 +68,7 @@ pub fn target() -> Target { position_independent_executables: true, pre_link_args: iter::once(( LinkerFlavor::Lld(LldFlavor::Ld), - PRE_LINK_ARGS.iter().cloned().map(String::from).collect(), + PRE_LINK_ARGS.iter().cloned().map(Cow::from).collect(), )) .collect(), override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()), From 1a1f5b89a4acf44fc4720c097b4bbcebcfa26818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BRANSTETT?= Date: Sun, 3 Apr 2022 18:42:39 +0200 Subject: [PATCH 09/10] Cleanup after some refactoring in rustc_target --- .../rustc_codegen_cranelift/src/driver/aot.rs | 8 +- compiler/rustc_codegen_gcc/src/lib.rs | 6 +- compiler/rustc_codegen_ssa/src/back/link.rs | 6 +- compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_target/src/spec/apple_base.rs | 4 +- .../src/spec/armv6k_nintendo_3ds.rs | 4 +- .../rustc_target/src/spec/dragonfly_base.rs | 4 +- .../rustc_target/src/spec/freebsd_base.rs | 4 +- .../rustc_target/src/spec/fuchsia_base.rs | 6 +- compiler/rustc_target/src/spec/haiku_base.rs | 4 +- .../rustc_target/src/spec/illumos_base.rs | 5 +- compiler/rustc_target/src/spec/l4re_base.rs | 5 +- compiler/rustc_target/src/spec/linux_base.rs | 4 +- .../rustc_target/src/spec/mipsel_sony_psp.rs | 4 +- compiler/rustc_target/src/spec/mod.rs | 87 +++++++++---------- .../rustc_target/src/spec/msp430_none_elf.rs | 3 +- compiler/rustc_target/src/spec/netbsd_base.rs | 4 +- .../rustc_target/src/spec/openbsd_base.rs | 4 +- compiler/rustc_target/src/spec/redox_base.rs | 4 +- .../src/spec/riscv32imc_esp_espidf.rs | 4 +- .../rustc_target/src/spec/solaris_base.rs | 4 +- .../src/spec/thumbv4t_none_eabi.rs | 3 +- .../rustc_target/src/spec/vxworks_base.rs | 4 +- .../rustc_target/src/spec/windows_gnu_base.rs | 4 +- .../src/spec/windows_msvc_base.rs | 4 +- 25 files changed, 79 insertions(+), 112 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 2e047c7eea1..5e1e1c81d26 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -304,8 +304,12 @@ pub(crate) fn run_aot( }; // FIXME handle `-Ctarget-cpu=native` - let target_cpu = - tcx.sess.opts.cg.target_cpu.as_ref().unwrap_or(&tcx.sess.target.cpu).to_owned(); + let target_cpu = match tcx.sess.opts.cg.target_cpu { + Some(ref name) => name, + None => tcx.sess.target.cpu.as_ref(), + } + .to_owned(); + Box::new(( CodegenResults { modules, diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index eac4a06226c..497a28354d8 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -287,8 +287,10 @@ fn handle_native(name: &str) -> &str { } pub fn target_cpu(sess: &Session) -> &str { - let name = sess.opts.cg.target_cpu.as_ref().unwrap_or(&sess.target.cpu); - handle_native(name) + match sess.opts.cg.target_cpu { + Some(ref name) => handle_native(name), + None => handle_native(sess.target.cpu.as_ref()), + } } pub fn target_features(sess: &Session) -> Vec { diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 40fe3c86e43..84a1043a6a0 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -675,10 +675,10 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( linker::disable_localization(&mut cmd); - for &(ref k, ref v) in sess.target.link_env.iter() { + for &(ref k, ref v) in sess.target.link_env.as_ref() { cmd.env(k.as_ref(), v.as_ref()); } - for k in sess.target.link_env_remove.iter() { + for k in sess.target.link_env_remove.as_ref() { cmd.env_remove(k.as_ref()); } @@ -1217,7 +1217,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { if let Some(ret) = infer_from( sess, - sess.target.linker.as_ref().map(|l| PathBuf::from(l.as_ref())), + sess.target.linker.as_deref().map(PathBuf::from), Some(sess.target.linker_flavor), ) { return ret; diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 408fd4ed2e6..4182a5d0711 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -956,7 +956,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { ret.reserve(7); // the minimum number of insertions // Target bindings. ret.insert((sym::target_os, Some(Symbol::intern(os)))); - for fam in sess.target.families.iter() { + for fam in sess.target.families.as_ref() { ret.insert((sym::target_family, Some(Symbol::intern(fam)))); if fam == "windows" { ret.insert((sym::windows, None)); diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index f2cef7996ff..238d3f8bda5 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -1,8 +1,6 @@ use std::{borrow::Cow, env}; -use crate::spec::{FramePointer, LldFlavor, SplitDebuginfo, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, FramePointer, LldFlavor, SplitDebuginfo, TargetOptions}; pub fn opts(os: &'static str) -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 diff --git a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs index 2e050b44156..ffcd1a3f4df 100644 --- a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs +++ b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs @@ -1,6 +1,4 @@ -use crate::spec::{LinkArgs, LinkerFlavor, RelocModel, Target, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, LinkArgs, LinkerFlavor, RelocModel, Target, TargetOptions}; /// A base target for Nintendo 3DS devices using the devkitARM toolchain. /// diff --git a/compiler/rustc_target/src/spec/dragonfly_base.rs b/compiler/rustc_target/src/spec/dragonfly_base.rs index 43072d63894..b59322d07f5 100644 --- a/compiler/rustc_target/src/spec/dragonfly_base.rs +++ b/compiler/rustc_target/src/spec/dragonfly_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/freebsd_base.rs b/compiler/rustc_target/src/spec/freebsd_base.rs index 05d60574f32..a7e0f9f7041 100644 --- a/compiler/rustc_target/src/spec/freebsd_base.rs +++ b/compiler/rustc_target/src/spec/freebsd_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index 2ee7047d7e0..04e30ff0c3e 100644 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ b/compiler/rustc_target/src/spec/fuchsia_base.rs @@ -1,6 +1,6 @@ -use crate::spec::{crt_objects, LinkArgs, LinkOutputKind, LinkerFlavor, LldFlavor, TargetOptions}; - -use super::cvs; +use crate::spec::{ + crt_objects, cvs, LinkArgs, LinkOutputKind, LinkerFlavor, LldFlavor, TargetOptions, +}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); diff --git a/compiler/rustc_target/src/spec/haiku_base.rs b/compiler/rustc_target/src/spec/haiku_base.rs index 25549491f4b..61c05a2bdb6 100644 --- a/compiler/rustc_target/src/spec/haiku_base.rs +++ b/compiler/rustc_target/src/spec/haiku_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/illumos_base.rs b/compiler/rustc_target/src/spec/illumos_base.rs index 1f6202dd7f5..ef8f90a4da8 100644 --- a/compiler/rustc_target/src/spec/illumos_base.rs +++ b/compiler/rustc_target/src/spec/illumos_base.rs @@ -1,7 +1,4 @@ -use crate::spec::{FramePointer, LinkArgs, LinkerFlavor, TargetOptions}; -use std::default::Default; - -use super::cvs; +use crate::spec::{cvs, FramePointer, LinkArgs, LinkerFlavor, TargetOptions}; pub fn opts() -> TargetOptions { let mut late_link_args = LinkArgs::new(); diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs index e185de78bca..7a051532f82 100644 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ b/compiler/rustc_target/src/spec/l4re_base.rs @@ -1,7 +1,4 @@ -use crate::spec::{LinkerFlavor, PanicStrategy, TargetOptions}; -use std::default::Default; - -use super::cvs; +use crate::spec::{cvs, LinkerFlavor, PanicStrategy, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/linux_base.rs b/compiler/rustc_target/src/spec/linux_base.rs index 84d8e19159a..0f79ada0d93 100644 --- a/compiler/rustc_target/src/spec/linux_base.rs +++ b/compiler/rustc_target/src/spec/linux_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs index dc8169b7118..45966b97d6a 100644 --- a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs +++ b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs @@ -1,7 +1,5 @@ +use crate::spec::{cvs, Target, TargetOptions}; use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, RelocModel}; -use crate::spec::{Target, TargetOptions}; - -use super::cvs; // The PSP has custom linker requirements. const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 96623e1c163..bd5b712c143 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -459,7 +459,7 @@ impl fmt::Display for LinkOutputKind { } } -pub type LinkArgs = BTreeMap>>; +pub type LinkArgs = BTreeMap>>; #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)] pub enum SplitDebuginfo { @@ -1028,19 +1028,16 @@ supported_targets! { } /// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> -// FIXME(Urgau): Figure out why the obvious form `["".into()].into()` doesn't work. macro_rules! cvs { () => { ::std::borrow::Cow::Borrowed(&[]) }; ($($x:expr),+ $(,)?) => { - { - ::std::borrow::Cow::Borrowed(&[ - $( - ::std::borrow::Cow::Borrowed($x), - )* - ]) - } + ::std::borrow::Cow::Borrowed(&[ + $( + ::std::borrow::Cow::Borrowed($x), + )* + ]) }; } @@ -1084,14 +1081,14 @@ impl TargetWarnings { #[derive(PartialEq, Clone, Debug)] pub struct Target { /// Target triple to pass to LLVM. - pub llvm_target: Cow<'static, str>, + pub llvm_target: StaticCow, /// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable. pub pointer_width: u32, /// Architecture to use for ABI considerations. Valid options include: "x86", /// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others. - pub arch: Cow<'static, str>, + pub arch: StaticCow, /// [Data layout](https://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM. - pub data_layout: Cow<'static, str>, + pub data_layout: StaticCow, /// Optional settings with defaults. pub options: TargetOptions, } @@ -1107,6 +1104,8 @@ impl HasTargetSpec for Target { } } +type StaticCow = Cow<'static, T>; + /// Optional aspects of a target specification. /// /// This has an implementation of `Default`, see each field for what the default is. In general, @@ -1123,25 +1122,25 @@ pub struct TargetOptions { /// Used as the `target_endian` `cfg` variable. Defaults to little endian. pub endian: Endian, /// Width of c_int type. Defaults to "32". - pub c_int_width: Cow<'static, str>, + pub c_int_width: StaticCow, /// OS name to use for conditional compilation (`target_os`). Defaults to "none". /// "none" implies a bare metal target without `std` library. /// A couple of targets having `std` also use "unknown" as an `os` value, /// but they are exceptions. - pub os: Cow<'static, str>, + pub os: StaticCow, /// Environment name to use for conditional compilation (`target_env`). Defaults to "". - pub env: Cow<'static, str>, + pub env: StaticCow, /// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"` /// or `"eabihf"`. Defaults to "". - pub abi: Cow<'static, str>, + pub abi: StaticCow, /// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown". - pub vendor: Cow<'static, str>, + pub vendor: StaticCow, /// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed /// on the command line. Defaults to `LinkerFlavor::Gcc`. pub linker_flavor: LinkerFlavor, /// Linker to invoke - pub linker: Option>, + pub linker: Option>, /// LLD flavor used if `lld` (or `rust-lld`) is specified as a linker /// without clarifying its flavor in any way. @@ -1176,23 +1175,23 @@ pub struct TargetOptions { /// Optional link script applied to `dylib` and `executable` crate types. /// This is a string containing the script, not a path. Can only be applied /// to linkers where `linker_is_gnu` is true. - pub link_script: Option>, + pub link_script: Option>, /// Environment variables to be set for the linker invocation. - pub link_env: Cow<'static, [(Cow<'static, str>, Cow<'static, str>)]>, + pub link_env: StaticCow<[(StaticCow, StaticCow)]>, /// Environment variables to be removed for the linker invocation. - pub link_env_remove: Cow<'static, [Cow<'static, str>]>, + pub link_env_remove: StaticCow<[StaticCow]>, /// Extra arguments to pass to the external assembler (when used) - pub asm_args: Cow<'static, [Cow<'static, str>]>, + pub asm_args: StaticCow<[StaticCow]>, /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults /// to "generic". - pub cpu: Cow<'static, str>, + pub cpu: StaticCow, /// Default target features to pass to LLVM. These features will *always* be /// passed, and cannot be disabled even via `-C`. Corresponds to `llc /// -mattr=$features`. - pub features: Cow<'static, str>, + pub features: StaticCow, /// Whether dynamic linking is available on this target. Defaults to false. pub dynamic_linking: bool, /// If dynamic linking is available, whether only cdylibs are supported. @@ -1216,21 +1215,21 @@ pub struct TargetOptions { /// Emit each function in its own section. Defaults to true. pub function_sections: bool, /// String to prepend to the name of every dynamic library. Defaults to "lib". - pub dll_prefix: Cow<'static, str>, + pub dll_prefix: StaticCow, /// String to append to the name of every dynamic library. Defaults to ".so". - pub dll_suffix: Cow<'static, str>, + pub dll_suffix: StaticCow, /// String to append to the name of every executable. - pub exe_suffix: Cow<'static, str>, + pub exe_suffix: StaticCow, /// String to prepend to the name of every static library. Defaults to "lib". - pub staticlib_prefix: Cow<'static, str>, + pub staticlib_prefix: StaticCow, /// String to append to the name of every static library. Defaults to ".a". - pub staticlib_suffix: Cow<'static, str>, + pub staticlib_suffix: StaticCow, /// Values of the `target_family` cfg set for this target. /// /// Common options are: "unix", "windows". Defaults to no families. /// /// See . - pub families: Cow<'static, [Cow<'static, str>]>, + pub families: StaticCow<[StaticCow]>, /// Whether the target toolchain's ABI supports returning small structs as an integer. pub abi_return_struct_as_int: bool, /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS, @@ -1302,7 +1301,7 @@ pub struct TargetOptions { /// LLVM to assemble an archive or fall back to the system linker, and /// currently only "gnu" is used to fall into LLVM. Unknown strings cause /// the system linker to be used. - pub archive_format: Cow<'static, str>, + pub archive_format: StaticCow, /// Is asm!() allowed? Defaults to true. pub allow_asm: bool, /// Whether the runtime startup code requires the `main` function be passed @@ -1318,7 +1317,7 @@ pub struct TargetOptions { /// Whether the target requires that emitted object code includes bitcode. pub forces_embed_bitcode: bool, /// Content of the LLVM cmdline section associated with embedded bitcode. - pub bitcode_llvm_cmdline: Cow<'static, str>, + pub bitcode_llvm_cmdline: StaticCow, /// Don't use this field; instead use the `.min_atomic_width()` method. pub min_atomic_width: Option, @@ -1390,7 +1389,7 @@ pub struct TargetOptions { /// If set, have the linker export exactly these symbols, instead of using /// the usual logic to figure this out from the crate itself. - pub override_export_symbols: Option]>>, + pub override_export_symbols: Option]>>, /// Determines how or whether the MergeFunctions LLVM pass should run for /// this target. Either "disabled", "trampolines", or "aliases". @@ -1401,16 +1400,16 @@ pub struct TargetOptions { pub merge_functions: MergeFunctions, /// Use platform dependent mcount function - pub mcount: Cow<'static, str>, + pub mcount: StaticCow, /// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers - pub llvm_abiname: Cow<'static, str>, + pub llvm_abiname: StaticCow, /// Whether or not RelaxElfRelocation flag will be passed to the linker pub relax_elf_relocations: bool, /// Additional arguments to pass to LLVM, similar to the `-C llvm-args` codegen option. - pub llvm_args: Cow<'static, [Cow<'static, str>]>, + pub llvm_args: StaticCow<[StaticCow]>, /// Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults /// to false (uses .init_array). @@ -1459,8 +1458,8 @@ impl Default for TargetOptions { endian: Endian::Little, c_int_width: "32".into(), os: "none".into(), - env: Cow::from(""), - abi: Cow::from(""), + env: "".into(), + abi: "".into(), vendor: "unknown".into(), linker_flavor: LinkerFlavor::Gcc, linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()), @@ -1468,9 +1467,9 @@ impl Default for TargetOptions { pre_link_args: LinkArgs::new(), post_link_args: LinkArgs::new(), link_script: None, - asm_args: Cow::Borrowed(&[]), + asm_args: cvs![], cpu: "generic".into(), - features: Cow::from(""), + features: "".into(), dynamic_linking: false, only_cdylib: false, executables: false, @@ -1482,7 +1481,7 @@ impl Default for TargetOptions { function_sections: true, dll_prefix: "lib".into(), dll_suffix: ".so".into(), - exe_suffix: Cow::from(""), + exe_suffix: "".into(), staticlib_prefix: "lib".into(), staticlib_suffix: ".a".into(), families: cvs![], @@ -1511,15 +1510,15 @@ impl Default for TargetOptions { late_link_args: LinkArgs::new(), late_link_args_dynamic: LinkArgs::new(), late_link_args_static: LinkArgs::new(), - link_env: Cow::Borrowed(&[]), - link_env_remove: Cow::Borrowed(&[]), + link_env: cvs![], + link_env_remove: cvs![], archive_format: "gnu".into(), main_needs_argc_argv: true, allow_asm: true, has_thread_local: false, obj_is_bitcode: false, forces_embed_bitcode: false, - bitcode_llvm_cmdline: Cow::from(""), + bitcode_llvm_cmdline: "".into(), min_atomic_width: None, max_atomic_width: None, atomic_cas: true, diff --git a/compiler/rustc_target/src/spec/msp430_none_elf.rs b/compiler/rustc_target/src/spec/msp430_none_elf.rs index f22c8672639..cedacb60f31 100644 --- a/compiler/rustc_target/src/spec/msp430_none_elf.rs +++ b/compiler/rustc_target/src/spec/msp430_none_elf.rs @@ -1,5 +1,4 @@ -use super::cvs; -use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions}; +use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions}; pub fn target() -> Target { Target { diff --git a/compiler/rustc_target/src/spec/netbsd_base.rs b/compiler/rustc_target/src/spec/netbsd_base.rs index a5fb58f5e7b..69016d77cf9 100644 --- a/compiler/rustc_target/src/spec/netbsd_base.rs +++ b/compiler/rustc_target/src/spec/netbsd_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/openbsd_base.rs b/compiler/rustc_target/src/spec/openbsd_base.rs index 7745d10e13e..bbd322bb6ce 100644 --- a/compiler/rustc_target/src/spec/openbsd_base.rs +++ b/compiler/rustc_target/src/spec/openbsd_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{FramePointer, RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, FramePointer, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/redox_base.rs b/compiler/rustc_target/src/spec/redox_base.rs index 667aa8e9c94..1878cc3fc11 100644 --- a/compiler/rustc_target/src/spec/redox_base.rs +++ b/compiler/rustc_target/src/spec/redox_base.rs @@ -1,6 +1,4 @@ -use crate::spec::{RelroLevel, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs index 4c7401380fd..0200862c7e0 100644 --- a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs @@ -1,7 +1,5 @@ +use crate::spec::{cvs, Target, TargetOptions}; use crate::spec::{LinkerFlavor, PanicStrategy, RelocModel}; -use crate::spec::{Target, TargetOptions}; - -use super::cvs; pub fn target() -> Target { Target { diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs index 8d8ad049b33..d61e1b2ec10 100644 --- a/compiler/rustc_target/src/spec/solaris_base.rs +++ b/compiler/rustc_target/src/spec/solaris_base.rs @@ -1,6 +1,4 @@ -use crate::spec::TargetOptions; - -use super::cvs; +use crate::spec::{cvs, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs index 457b78850ac..8d6130a8a79 100644 --- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs @@ -8,8 +8,7 @@ //! //! **Important:** This target profile **does not** specify a linker script. You just get the default link script when you build a binary for this target. The default link script is very likely wrong, so you should use `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. -use super::cvs; -use crate::spec::{LinkerFlavor, Target, TargetOptions}; +use crate::spec::{cvs, LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { Target { diff --git a/compiler/rustc_target/src/spec/vxworks_base.rs b/compiler/rustc_target/src/spec/vxworks_base.rs index f43cea131b7..2beb279e398 100644 --- a/compiler/rustc_target/src/spec/vxworks_base.rs +++ b/compiler/rustc_target/src/spec/vxworks_base.rs @@ -1,6 +1,4 @@ -use crate::spec::TargetOptions; - -use super::cvs; +use crate::spec::{cvs, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs index 1e5ced684bd..d11f1f7d3f8 100644 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs @@ -1,7 +1,5 @@ use crate::spec::crt_objects::{self, CrtObjectsFallback}; -use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, TargetOptions}; - -use super::cvs; +use crate::spec::{cvs, LinkArgs, LinkerFlavor, LldFlavor, TargetOptions}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); diff --git a/compiler/rustc_target/src/spec/windows_msvc_base.rs b/compiler/rustc_target/src/spec/windows_msvc_base.rs index bfe8edecac4..21062c337d8 100644 --- a/compiler/rustc_target/src/spec/windows_msvc_base.rs +++ b/compiler/rustc_target/src/spec/windows_msvc_base.rs @@ -1,6 +1,4 @@ -use crate::spec::TargetOptions; - -use super::cvs; +use crate::spec::{cvs, TargetOptions}; pub fn opts() -> TargetOptions { let base = super::msvc_base::opts(); From f4a7ed433834e8ea2775097a9bf433880d6e34a3 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 3 Apr 2022 13:23:27 -0400 Subject: [PATCH 10/10] Fix &mut invalidation in ptr::swap doctest Under Stacked Borrows with raw pointer tagging, the previous code was UB because the code which creates the the second pointer borrows the array through a tag in the borrow stacks below the Unique tag that our first pointer is based on, thus invalidating the first pointer. This is not definitely a bug and may never be real UB, but I desperately want people to write code that conforms to SB with raw pointer tagging so that I can write good diagnostics. The alternative aliasing models aren't possible to diagnose well due to state space explosion. Therefore, it would be super cool if the standard library nudged people towards writing code that is valid with respect to SB with raw pointer tagging. --- library/core/src/ptr/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index e2a19c1b581..91e2bd7953f 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -637,8 +637,9 @@ pub const fn slice_from_raw_parts_mut(data: *mut T, len: usize) -> *mut [T] { /// /// let mut array = [0, 1, 2, 3]; /// -/// let x = array[0..].as_mut_ptr() as *mut [u32; 2]; // this is `array[0..2]` -/// let y = array[2..].as_mut_ptr() as *mut [u32; 2]; // this is `array[2..4]` +/// let (x, y) = array.split_at_mut(2); +/// let x = x.as_mut_ptr().cast::<[u32; 2]>(); // this is `array[0..2]` +/// let y = y.as_mut_ptr().cast::<[u32; 2]>(); // this is `array[2..4]` /// /// unsafe { /// ptr::swap(x, y);