Skip to content

Commit bd68693

Browse files
committed
Auto merge of rust-lang#136850 - jhpratt:rollup-rm72dxb, r=jhpratt
Rollup of 6 pull requests Successful merges: - rust-lang#134999 (Add cygwin target.) - rust-lang#135677 (Small `rustc_resolve` cleanups) - rust-lang#136699 (std: replace the `FromInner` implementation for addresses with private conversion functions) - rust-lang#136758 (tests: `-Copt-level=3` instead of `-O` in assembly tests) - rust-lang#136761 (tests: `-Copt-level=3` instead of `-O` in codegen tests) - rust-lang#136833 (compiler: die immediately instead of handling unknown target codegen) Failed merges: - rust-lang#136808 (Try to recover from path sep error in type parsing) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c182ce9 + f5ef201 commit bd68693

File tree

294 files changed

+648
-747
lines changed

Some content is hidden

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

294 files changed

+648
-747
lines changed

Diff for: compiler/rustc_codegen_gcc/src/int.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
400400
conv: Conv::C,
401401
can_unwind: false,
402402
};
403-
fn_abi.adjust_for_foreign_abi(self.cx, ExternAbi::C { unwind: false }).unwrap();
403+
fn_abi.adjust_for_foreign_abi(self.cx, ExternAbi::C { unwind: false });
404404

405405
let ret_indirect = matches!(fn_abi.ret.mode, PassMode::Indirect { .. });
406406

Diff for: compiler/rustc_const_eval/src/errors.rs

-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rustc_middle::mir::interpret::{
1616
};
1717
use rustc_middle::ty::{self, Mutability, Ty};
1818
use rustc_span::{Span, Symbol};
19-
use rustc_target::callconv::AdjustForForeignAbiError;
2019

2120
use crate::interpret::InternKind;
2221

@@ -936,9 +935,6 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
936935
InvalidProgramInfo::TooGeneric => const_eval_too_generic,
937936
InvalidProgramInfo::AlreadyReported(_) => const_eval_already_reported,
938937
InvalidProgramInfo::Layout(e) => e.diagnostic_message(),
939-
InvalidProgramInfo::FnAbiAdjustForForeignAbi(_) => {
940-
rustc_middle::error::middle_adjust_for_foreign_abi_error
941-
}
942938
}
943939
}
944940
fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
@@ -953,12 +949,6 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
953949
}
954950
dummy_diag.cancel();
955951
}
956-
InvalidProgramInfo::FnAbiAdjustForForeignAbi(
957-
AdjustForForeignAbiError::Unsupported { arch, abi },
958-
) => {
959-
diag.arg("arch", arch);
960-
diag.arg("abi", abi.name());
961-
}
962952
}
963953
}
964954
}

Diff for: compiler/rustc_const_eval/src/interpret/eval_context.rs

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ impl<'tcx, M: Machine<'tcx>> FnAbiOfHelpers<'tcx> for InterpCx<'tcx, M> {
106106
) -> InterpErrorKind<'tcx> {
107107
match err {
108108
FnAbiError::Layout(err) => err_inval!(Layout(err)),
109-
FnAbiError::AdjustForForeignAbi(err) => {
110-
err_inval!(FnAbiAdjustForForeignAbi(err))
111-
}
112109
}
113110
}
114111
}

Diff for: compiler/rustc_middle/src/mir/interpret/error.rs

-4
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,6 @@ pub enum InvalidProgramInfo<'tcx> {
216216
AlreadyReported(ReportedErrorInfo),
217217
/// An error occurred during layout computation.
218218
Layout(layout::LayoutError<'tcx>),
219-
/// An error occurred during FnAbi computation: the passed --target lacks FFI support
220-
/// (which unfortunately typeck does not reject).
221-
/// Not using `FnAbiError` as that contains a nested `LayoutError`.
222-
FnAbiAdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError),
223219
}
224220

225221
/// Details of why a pointer had to be in-bounds.

Diff for: compiler/rustc_middle/src/ty/layout.rs

-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use rustc_target::spec::{
2424
use tracing::debug;
2525
use {rustc_abi as abi, rustc_hir as hir};
2626

27-
use crate::error::UnsupportedFnAbi;
2827
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
2928
use crate::query::TyCtxtAt;
3029
use crate::ty::normalize_erasing_regions::NormalizationError;
@@ -1275,18 +1274,12 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: ExternAbi)
12751274
pub enum FnAbiError<'tcx> {
12761275
/// Error produced by a `layout_of` call, while computing `FnAbi` initially.
12771276
Layout(LayoutError<'tcx>),
1278-
1279-
/// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI.
1280-
AdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError),
12811277
}
12821278

12831279
impl<'a, 'b, G: EmissionGuarantee> Diagnostic<'a, G> for FnAbiError<'b> {
12841280
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
12851281
match self {
12861282
Self::Layout(e) => e.into_diagnostic().into_diag(dcx, level),
1287-
Self::AdjustForForeignAbi(
1288-
rustc_target::callconv::AdjustForForeignAbiError::Unsupported { arch, abi },
1289-
) => UnsupportedFnAbi { arch, abi: abi.name() }.into_diag(dcx, level),
12901283
}
12911284
}
12921285
}

Diff for: compiler/rustc_passes/src/abi_test.rs

-9
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ fn unwrap_fn_abi<'tcx>(
4646
span: tcx.def_span(item_def_id),
4747
});
4848
}
49-
Err(FnAbiError::AdjustForForeignAbi(e)) => {
50-
// Sadly there seems to be no `into_diagnostic` for this case... and I am not sure if
51-
// this can even be reached. Anyway this is a perma-unstable debug attribute, an ICE
52-
// isn't the worst thing. Also this matches what codegen does.
53-
span_bug!(
54-
tcx.def_span(item_def_id),
55-
"error computing fn_abi_of_instance, cannot adjust for foreign ABI: {e:?}",
56-
)
57-
}
5849
}
5950
}
6051

Diff for: compiler/rustc_resolve/src/diagnostics.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11271127
});
11281128

11291129
// Make sure error reporting is deterministic.
1130-
suggestions.sort_by(|a, b| a.candidate.as_str().partial_cmp(b.candidate.as_str()).unwrap());
1130+
suggestions.sort_by(|a, b| a.candidate.as_str().cmp(b.candidate.as_str()));
11311131

11321132
match find_best_match_for_name(
11331133
&suggestions.iter().map(|suggestion| suggestion.candidate).collect::<Vec<Symbol>>(),
@@ -2256,14 +2256,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22562256
mut path: Vec<Segment>,
22572257
parent_scope: &ParentScope<'ra>,
22582258
) -> Option<(Vec<Segment>, Option<String>)> {
2259-
match (path.get(0), path.get(1)) {
2259+
match path[..] {
22602260
// `{{root}}::ident::...` on both editions.
22612261
// On 2015 `{{root}}` is usually added implicitly.
2262-
(Some(fst), Some(snd))
2263-
if fst.ident.name == kw::PathRoot && !snd.ident.is_path_segment_keyword() => {}
2262+
[first, second, ..]
2263+
if first.ident.name == kw::PathRoot && !second.ident.is_path_segment_keyword() => {}
22642264
// `ident::...` on 2018.
2265-
(Some(fst), _)
2266-
if fst.ident.span.at_least_rust_2018() && !fst.ident.is_path_segment_keyword() =>
2265+
[first, ..]
2266+
if first.ident.span.at_least_rust_2018()
2267+
&& !first.ident.is_path_segment_keyword() =>
22672268
{
22682269
// Insert a placeholder that's later replaced by `self`/`super`/etc.
22692270
path.insert(0, Segment::from_ident(Ident::empty()));
@@ -2374,7 +2375,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23742375
// 2) `std` suggestions before `core` suggestions.
23752376
let mut extern_crate_names =
23762377
self.extern_prelude.keys().map(|ident| ident.name).collect::<Vec<_>>();
2377-
extern_crate_names.sort_by(|a, b| b.as_str().partial_cmp(a.as_str()).unwrap());
2378+
extern_crate_names.sort_by(|a, b| b.as_str().cmp(a.as_str()));
23782379

23792380
for name in extern_crate_names.into_iter() {
23802381
// Replace first ident with a crate name and check if that is valid.

Diff for: compiler/rustc_target/src/callconv/mod.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_abi::{
66
Size, TyAbiInterface, TyAndLayout,
77
};
88
use rustc_macros::HashStable_Generic;
9-
use rustc_span::Symbol;
109

1110
use crate::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, WasmCAbi};
1211

@@ -623,19 +622,8 @@ impl<'a, Ty: fmt::Display> fmt::Debug for FnAbi<'a, Ty> {
623622
}
624623
}
625624

626-
/// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI.
627-
#[derive(Copy, Clone, Debug, HashStable_Generic)]
628-
pub enum AdjustForForeignAbiError {
629-
/// Target architecture doesn't support "foreign" (i.e. non-Rust) ABIs.
630-
Unsupported { arch: Symbol, abi: ExternAbi },
631-
}
632-
633625
impl<'a, Ty> FnAbi<'a, Ty> {
634-
pub fn adjust_for_foreign_abi<C>(
635-
&mut self,
636-
cx: &C,
637-
abi: ExternAbi,
638-
) -> Result<(), AdjustForForeignAbiError>
626+
pub fn adjust_for_foreign_abi<C>(&mut self, cx: &C, abi: ExternAbi)
639627
where
640628
Ty: TyAbiInterface<'a, C> + Copy,
641629
C: HasDataLayout + HasTargetSpec + HasWasmCAbiOpt + HasX86AbiOpt,
@@ -644,7 +632,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
644632
if let Some(arg) = self.args.first_mut() {
645633
arg.pass_by_stack_offset(None);
646634
}
647-
return Ok(());
635+
return;
648636
}
649637

650638
let spec = cx.target_spec();
@@ -719,15 +707,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
719707
}
720708
"wasm64" => wasm::compute_c_abi_info(cx, self),
721709
"bpf" => bpf::compute_abi_info(self),
722-
arch => {
723-
return Err(AdjustForForeignAbiError::Unsupported {
724-
arch: Symbol::intern(arch),
725-
abi,
726-
});
727-
}
710+
arch => panic!("no lowering implemented for {arch}"),
728711
}
729-
730-
Ok(())
731712
}
732713

733714
pub fn adjust_for_rust_abi<C>(&mut self, cx: &C, abi: ExternAbi)

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

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use std::borrow::Cow;
2+
3+
use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs};
4+
5+
pub(crate) fn opts() -> TargetOptions {
6+
let mut pre_link_args = TargetOptions::link_args(
7+
LinkerFlavor::Gnu(Cc::No, Lld::No),
8+
&["--disable-dynamicbase", "--enable-auto-image-base"],
9+
);
10+
crate::spec::add_link_args(
11+
&mut pre_link_args,
12+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
13+
&["-Wl,--disable-dynamicbase", "-Wl,--enable-auto-image-base"],
14+
);
15+
let cygwin_libs = &["-lcygwin", "-lgcc", "-lcygwin", "-luser32", "-lkernel32", "-lgcc_s"];
16+
let mut late_link_args =
17+
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), cygwin_libs);
18+
crate::spec::add_link_args(
19+
&mut late_link_args,
20+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
21+
cygwin_libs,
22+
);
23+
TargetOptions {
24+
os: "cygwin".into(),
25+
vendor: "pc".into(),
26+
// FIXME(#13846) this should be enabled for cygwin
27+
function_sections: false,
28+
linker: Some("gcc".into()),
29+
dynamic_linking: true,
30+
dll_prefix: "".into(),
31+
dll_suffix: ".dll".into(),
32+
exe_suffix: ".exe".into(),
33+
families: cvs!["unix"],
34+
is_like_windows: true,
35+
allows_weak_linkage: false,
36+
pre_link_args,
37+
late_link_args,
38+
abi_return_struct_as_int: true,
39+
emit_debug_gdb_scripts: false,
40+
requires_uwtable: true,
41+
eh_frame_header: false,
42+
debuginfo_kind: DebuginfoKind::Dwarf,
43+
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
44+
..Default::default()
45+
}
46+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub(crate) mod android;
33
pub(crate) mod apple;
44
pub(crate) mod avr_gnu;
55
pub(crate) mod bpf;
6+
pub(crate) mod cygwin;
67
pub(crate) mod dragonfly;
78
pub(crate) mod freebsd;
89
pub(crate) mod fuchsia;

Diff for: compiler/rustc_target/src/spec/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,7 @@ supported_targets! {
20132013
("riscv64imac-unknown-nuttx-elf", riscv64imac_unknown_nuttx_elf),
20142014
("riscv64gc-unknown-nuttx-elf", riscv64gc_unknown_nuttx_elf),
20152015

2016+
("x86_64-pc-cygwin", x86_64_pc_cygwin),
20162017
}
20172018

20182019
/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
@@ -2994,8 +2995,8 @@ impl Target {
29942995
);
29952996
check_eq!(
29962997
self.is_like_windows,
2997-
self.os == "windows" || self.os == "uefi",
2998-
"`is_like_windows` must be set if and only if `os` is `windows` or `uefi`"
2998+
self.os == "windows" || self.os == "uefi" || self.os == "cygwin",
2999+
"`is_like_windows` must be set if and only if `os` is `windows`, `uefi` or `cygwin`"
29993000
);
30003001
check_eq!(
30013002
self.is_like_wasm,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{Cc, LinkerFlavor, Lld, Target, base};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = base::cygwin::opts();
5+
base.cpu = "x86-64".into();
6+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "i386pep"]);
7+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
8+
base.max_atomic_width = Some(64);
9+
base.linker = Some("x86_64-pc-cygwin-gcc".into());
10+
Target {
11+
llvm_target: "x86_64-pc-cygwin".into(),
12+
pointer_width: 64,
13+
data_layout:
14+
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
15+
arch: "x86_64".into(),
16+
options: base,
17+
metadata: crate::spec::TargetMetadata {
18+
description: Some("64-bit x86 Cygwin".into()),
19+
tier: Some(3),
20+
host_tools: Some(false),
21+
std: None,
22+
},
23+
}
24+
}

Diff for: compiler/rustc_ty_utils/src/abi.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ fn fn_abi_new_uncached<'tcx>(
650650
conv,
651651
can_unwind: fn_can_unwind(cx.tcx(), fn_def_id, sig.abi),
652652
};
653-
fn_abi_adjust_for_abi(cx, &mut fn_abi, sig.abi, fn_def_id)?;
653+
fn_abi_adjust_for_abi(cx, &mut fn_abi, sig.abi, fn_def_id);
654654
debug!("fn_abi_new_uncached = {:?}", fn_abi);
655655
fn_abi_sanity_check(cx, &fn_abi, sig.abi);
656656
Ok(tcx.arena.alloc(fn_abi))
@@ -662,7 +662,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
662662
fn_abi: &mut FnAbi<'tcx, Ty<'tcx>>,
663663
abi: ExternAbi,
664664
fn_def_id: Option<DefId>,
665-
) -> Result<(), &'tcx FnAbiError<'tcx>> {
665+
) {
666666
if abi == ExternAbi::Unadjusted {
667667
// The "unadjusted" ABI passes aggregates in "direct" mode. That's fragile but needed for
668668
// some LLVM intrinsics.
@@ -682,7 +682,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
682682
for arg in fn_abi.args.iter_mut() {
683683
unadjust(arg);
684684
}
685-
return Ok(());
685+
return;
686686
}
687687

688688
let tcx = cx.tcx();
@@ -723,12 +723,8 @@ fn fn_abi_adjust_for_abi<'tcx>(
723723
}
724724
}
725725
} else {
726-
fn_abi
727-
.adjust_for_foreign_abi(cx, abi)
728-
.map_err(|err| &*tcx.arena.alloc(FnAbiError::AdjustForForeignAbi(err)))?;
726+
fn_abi.adjust_for_foreign_abi(cx, abi);
729727
}
730-
731-
Ok(())
732728
}
733729

734730
#[tracing::instrument(level = "debug", skip(cx))]

Diff for: library/std/src/net/ip_addr.rs

-29
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,3 @@ pub use core::net::IpAddr;
88
pub use core::net::Ipv6MulticastScope;
99
#[stable(feature = "rust1", since = "1.0.0")]
1010
pub use core::net::{Ipv4Addr, Ipv6Addr};
11-
12-
use crate::sys::net::netc as c;
13-
use crate::sys_common::{FromInner, IntoInner};
14-
15-
impl IntoInner<c::in_addr> for Ipv4Addr {
16-
#[inline]
17-
fn into_inner(self) -> c::in_addr {
18-
// `s_addr` is stored as BE on all machines and the array is in BE order.
19-
// So the native endian conversion method is used so that it's never swapped.
20-
c::in_addr { s_addr: u32::from_ne_bytes(self.octets()) }
21-
}
22-
}
23-
impl FromInner<c::in_addr> for Ipv4Addr {
24-
fn from_inner(addr: c::in_addr) -> Ipv4Addr {
25-
Ipv4Addr::from(addr.s_addr.to_ne_bytes())
26-
}
27-
}
28-
29-
impl IntoInner<c::in6_addr> for Ipv6Addr {
30-
fn into_inner(self) -> c::in6_addr {
31-
c::in6_addr { s6_addr: self.octets() }
32-
}
33-
}
34-
impl FromInner<c::in6_addr> for Ipv6Addr {
35-
#[inline]
36-
fn from_inner(addr: c::in6_addr) -> Ipv6Addr {
37-
Ipv6Addr::from(addr.s6_addr)
38-
}
39-
}

0 commit comments

Comments
 (0)