Skip to content

Commit

Permalink
clarify target_feature + forced inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtwco committed Jan 10, 2025
1 parent 3169a44 commit ce602ac
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,17 +627,19 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
// enabled. For that reason we also forbid `#[inline(always)]` as it can't be
// respected.
//
// `#[rustc_force_inline]` doesn't need to be prohibited here, that
// is implemented entirely in rustc can attempt to inline and error if it cannot.
// `#[rustc_force_inline]` doesn't need to be prohibited here, only
// `#[inline(always)]`, as forced inlining is implemented entirely within
// rustc (and so the MIR inliner can do any necessary checks for compatible target
// features).
//
// This sidesteps the LLVM blockers in enabling `target_features` +
// `inline(always)` to be used together (see rust-lang/rust#116573 and
// llvm/llvm-project#70563).
if !codegen_fn_attrs.target_features.is_empty()
&& matches!(codegen_fn_attrs.inline, InlineAttr::Always)
{
if let Some(span) = inline_span {
tcx.dcx().span_err(
span,
"cannot use `#[inline(always)]` with \
`#[target_feature]`",
);
tcx.dcx().span_err(span, "cannot use `#[inline(always)]` with `#[target_feature]`");
}
}

Expand Down

0 comments on commit ce602ac

Please sign in to comment.