Skip to content

Commit 4abcd79

Browse files
committed
rustc_codegen_ssa: flatten nested ifs
1 parent 428a25c commit 4abcd79

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1537,8 +1537,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
15371537
// Spin up what work we can, only doing this while we've got available
15381538
// parallelism slots and work left to spawn.
15391539
if codegen_state != Aborted {
1540-
while !work_items.is_empty() && running_with_own_token < tokens.len() {
1541-
let (item, _) = work_items.pop().unwrap();
1540+
while running_with_own_token < tokens.len()
1541+
&& let Some((item, _)) = work_items.pop()
1542+
{
15421543
spawn_work(
15431544
&cgcx,
15441545
&mut llvm_start_time,

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+15-20
Original file line numberDiff line numberDiff line change
@@ -656,25 +656,20 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
656656
// llvm/llvm-project#70563).
657657
if !codegen_fn_attrs.target_features.is_empty()
658658
&& matches!(codegen_fn_attrs.inline, InlineAttr::Always)
659+
&& let Some(span) = inline_span
659660
{
660-
if let Some(span) = inline_span {
661-
tcx.dcx().span_err(span, "cannot use `#[inline(always)]` with `#[target_feature]`");
662-
}
661+
tcx.dcx().span_err(span, "cannot use `#[inline(always)]` with `#[target_feature]`");
663662
}
664663

665-
if !codegen_fn_attrs.no_sanitize.is_empty() && codegen_fn_attrs.inline.always() {
666-
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
667-
let hir_id = tcx.local_def_id_to_hir_id(did);
668-
tcx.node_span_lint(
669-
lint::builtin::INLINE_NO_SANITIZE,
670-
hir_id,
671-
no_sanitize_span,
672-
|lint| {
673-
lint.primary_message("`no_sanitize` will have no effect after inlining");
674-
lint.span_note(inline_span, "inlining requested here");
675-
},
676-
)
677-
}
664+
if !codegen_fn_attrs.no_sanitize.is_empty()
665+
&& codegen_fn_attrs.inline.always()
666+
&& let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span)
667+
{
668+
let hir_id = tcx.local_def_id_to_hir_id(did);
669+
tcx.node_span_lint(lint::builtin::INLINE_NO_SANITIZE, hir_id, no_sanitize_span, |lint| {
670+
lint.primary_message("`no_sanitize` will have no effect after inlining");
671+
lint.span_note(inline_span, "inlining requested here");
672+
})
678673
}
679674

680675
// Weak lang items have the same semantics as "std internal" symbols in the
@@ -704,10 +699,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
704699
// Any linkage to LLVM intrinsics for now forcibly marks them all as never
705700
// unwinds since LLVM sometimes can't handle codegen which `invoke`s
706701
// intrinsic functions.
707-
if let Some(name) = &codegen_fn_attrs.link_name {
708-
if name.as_str().starts_with("llvm.") {
709-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND;
710-
}
702+
if let Some(name) = &codegen_fn_attrs.link_name
703+
&& name.as_str().starts_with("llvm.")
704+
{
705+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND;
711706
}
712707

713708
if let Some(features) = check_tied_features(

compiler/rustc_codegen_ssa/src/mir/block.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
990990
});
991991

992992
// Split the rust-call tupled arguments off.
993-
let (first_args, untuple) = if abi == ExternAbi::RustCall && !args.is_empty() {
994-
let (tup, args) = args.split_last().unwrap();
993+
let (first_args, untuple) = if abi == ExternAbi::RustCall
994+
&& let Some((tup, args)) = args.split_last()
995+
{
995996
(args, Some(tup))
996997
} else {
997998
(args, None)

0 commit comments

Comments
 (0)