Skip to content

Commit fa12fdb

Browse files
committed
Fix review comments
1 parent c3367db commit fa12fdb

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

compiler/rustc_middle/src/ty/layout.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -2736,13 +2736,14 @@ where
27362736
let arg_of = |ty: Ty<'tcx>, arg_idx: Option<usize>| {
27372737
let is_return = arg_idx.is_none();
27382738

2739+
let layout = cx.layout_of(ty);
27392740
let layout = if force_thin_self_ptr && arg_idx == Some(0) {
27402741
// Don't pass the vtable, it's not an argument of the virtual fn.
27412742
// Instead, pass just the data pointer, but give it the type `*const/mut dyn Trait`
27422743
// or `&/&mut dyn Trait` because this is special-cased elsewhere in codegen
2743-
make_thin_self_ptr(cx, cx.layout_of(ty))
2744+
make_thin_self_ptr(cx, layout)
27442745
} else {
2745-
cx.layout_of(ty)
2746+
layout
27462747
};
27472748

27482749
let mut arg = ArgAbi::new(cx, layout, |layout, scalar, offset| {
@@ -2842,11 +2843,9 @@ where
28422843
let max_by_val_size = Pointer.size(cx) * 2;
28432844
let size = arg.layout.size;
28442845

2845-
assert!(
2846-
matches!(arg.mode, PassMode::Indirect { on_stack: false, .. }),
2847-
"{:?}",
2848-
arg
2849-
);
2846+
let is_indirect_not_on_stack =
2847+
matches!(arg.mode, PassMode::Indirect { on_stack: false, .. });
2848+
assert!(is_indirect_not_on_stack, "{:?}", arg);
28502849
if !arg.layout.is_unsized() && size <= max_by_val_size {
28512850
// We want to pass small aggregates as immediates, but using
28522851
// a LLVM aggregate type for this leads to bad optimizations,

0 commit comments

Comments
 (0)