Skip to content

Commit 499fca9

Browse files
authored
Rollup merge of rust-lang#152984 - stellanomia:remove-redundant-inline-check, r=JonathanBrouwer
Remove redundant call to `check_codegen_attributes_extra` in Inliner Inside `try_inlining`, `check_codegen_attributes` is called first. This function internally invokes `check_codegen_attributes_extra`. However, immediately after that returns, `try_inlining` calls `check_codegen_attributes_extra` again. First call: https://github.com/rust-lang/rust/blob/7ec34defe9e62a1a6946d3e700b5903d8dc89ece/compiler/rustc_mir_transform/src/inline.rs#L800-L814 Second call: https://github.com/rust-lang/rust/blob/7ec34defe9e62a1a6946d3e700b5903d8dc89ece/compiler/rustc_mir_transform/src/inline.rs#L598-L612 ```rust // Inside try_inlining: check_codegen_attributes(inliner, callsite, callee_attrs)?; // Internally calls `check_codegen_attributes_extra` inliner.check_codegen_attributes_extra(callee_attrs)?; // Called again here ``` In `try_inlining`, inliner is held as a shared reference (`&I`). Since `check_codegen_attributes_extra` takes `&self` and does not rely on interior mutability or external state, there does not seem to be any state change between the two calls. Therefore, the second call appears to be redundant. Currently, `check_codegen_attributes` is only called from `try_inlining`, and `check_codegen_attributes_extra` appears to be called only from these two locations. It seems reasonable for the `check_codegen_attributes` wrapper to handle the hook automatically.
2 parents 867a480 + febd3b9 commit 499fca9

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
607607
let callee_attrs = callee_attrs.as_ref();
608608
check_inline::is_inline_valid_on_fn(tcx, callsite.callee.def_id())?;
609609
check_codegen_attributes(inliner, callsite, callee_attrs)?;
610-
inliner.check_codegen_attributes_extra(callee_attrs)?;
611610

612611
let terminator = caller_body[callsite.block].terminator.as_ref().unwrap();
613612
let TerminatorKind::Call { args, destination, .. } = &terminator.kind else { bug!() };

0 commit comments

Comments
 (0)