Skip to content

Commit 99b18d6

Browse files
committedJun 24, 2025·
Auto merge of #142929 - workingjubilee:rollup-4p3ypz1, r=workingjubilee
Rollup of 9 pull requests Successful merges: - #140985 (Change `core::iter::Fuse`'s `Default` impl to do what its docs say it does) - #141324 (std: sys: random: uefi: Provide rdrand based fallback) - #142134 (Reject unsupported `extern "{abi}"`s consistently in all positions) - #142784 (Add codegen timing section) - #142827 (Move error code explanation removal check into tidy) - #142873 (Don't suggest changing a method inside a expansion) - #142908 (Fix install-template.sh for Solaris tr) - #142922 (Fix comment on NoMangle) - #142923 (fix `-Zmin-function-alignment` on functions without attributes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 706f244 + b7a9cd8 commit 99b18d6

File tree

63 files changed

+1665
-2860
lines changed

Some content is hidden

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

63 files changed

+1665
-2860
lines changed
 

‎compiler/rustc_ast_lowering/src/item.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_abi::ExternAbi;
22
use rustc_ast::ptr::P;
33
use rustc_ast::visit::AssocCtxt;
44
use rustc_ast::*;
5-
use rustc_errors::ErrorGuaranteed;
5+
use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err};
66
use rustc_hir::def::{DefKind, PerNS, Res};
77
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
88
use rustc_hir::{self as hir, HirId, LifetimeSource, PredicateOrigin};
@@ -1644,9 +1644,29 @@ impl<'hir> LoweringContext<'_, 'hir> {
16441644
self.error_on_invalid_abi(abi_str);
16451645
ExternAbi::Rust
16461646
});
1647-
let sess = self.tcx.sess;
1648-
let features = self.tcx.features();
1649-
gate_unstable_abi(sess, features, span, extern_abi);
1647+
let tcx = self.tcx;
1648+
1649+
// we can't do codegen for unsupported ABIs, so error now so we won't get farther
1650+
if !tcx.sess.target.is_abi_supported(extern_abi) {
1651+
let mut err = struct_span_code_err!(
1652+
tcx.dcx(),
1653+
span,
1654+
E0570,
1655+
"{extern_abi} is not a supported ABI for the current target",
1656+
);
1657+
1658+
if let ExternAbi::Stdcall { unwind } = extern_abi {
1659+
let c_abi = ExternAbi::C { unwind };
1660+
let system_abi = ExternAbi::System { unwind };
1661+
err.help(format!("if you need `extern {extern_abi}` on win32 and `extern {c_abi}` everywhere else, \
1662+
use `extern {system_abi}`"
1663+
));
1664+
}
1665+
err.emit();
1666+
}
1667+
// Show required feature gate even if we already errored, as the user is likely to build the code
1668+
// for the actually intended target next and then they will need the feature gate.
1669+
gate_unstable_abi(tcx.sess, tcx.features(), span, extern_abi);
16501670
extern_abi
16511671
}
16521672

‎compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
146146
}
147147
}
148148

149-
// Apply the minimum function alignment here, so that individual backends don't have to.
150-
codegen_fn_attrs.alignment = Ord::max(
151-
codegen_fn_attrs.alignment,
152-
tcx.sess.opts.unstable_opts.min_function_alignment,
153-
);
154-
155149
let Some(Ident { name, .. }) = attr.ident() else {
156150
continue;
157151
};
@@ -454,6 +448,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
454448

455449
mixed_export_name_no_mangle_lint_state.lint_if_mixed(tcx);
456450

451+
// Apply the minimum function alignment here, so that individual backends don't have to.
452+
codegen_fn_attrs.alignment =
453+
Ord::max(codegen_fn_attrs.alignment, tcx.sess.opts.unstable_opts.min_function_alignment);
454+
457455
let inline_span;
458456
(codegen_fn_attrs.inline, inline_span) = if let Some((inline_attr, span)) =
459457
find_attr!(attrs, AttributeKind::Inline(i, span) => (*i, *span))

0 commit comments

Comments
 (0)
Please sign in to comment.