Skip to content

Commit 1f56ff8

Browse files
committed
rustc_monomorphize: Reduce check_move_size() indentation
1 parent af86069 commit 1f56ff8

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

compiler/rustc_monomorphize/src/collector.rs

+26-27
Original file line numberDiff line numberDiff line change
@@ -609,34 +609,33 @@ impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> {
609609
let limit = Size::from_bytes(limit);
610610
let ty = operand.ty(self.body, self.tcx);
611611
let ty = self.monomorphize(ty);
612-
let layout = self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty));
613-
if let Ok(layout) = layout {
614-
if layout.size > limit {
615-
debug!(?layout);
616-
let source_info = self.body.source_info(location);
617-
debug!(?source_info);
618-
let lint_root = source_info.scope.lint_root(&self.body.source_scopes);
619-
debug!(?lint_root);
620-
let Some(lint_root) = lint_root else {
621-
// This happens when the issue is in a function from a foreign crate that
622-
// we monomorphized in the current crate. We can't get a `HirId` for things
623-
// in other crates.
624-
// FIXME: Find out where to report the lint on. Maybe simply crate-level lint root
625-
// but correct span? This would make the lint at least accept crate-level lint attributes.
626-
return;
627-
};
628-
self.tcx.emit_spanned_lint(
629-
LARGE_ASSIGNMENTS,
630-
lint_root,
631-
source_info.span,
632-
LargeAssignmentsLint {
633-
span: source_info.span,
634-
size: layout.size.bytes(),
635-
limit: limit.bytes(),
636-
},
637-
)
638-
}
612+
let Ok(layout) = self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)) else { return };
613+
if layout.size <= limit {
614+
return;
639615
}
616+
debug!(?layout);
617+
let source_info = self.body.source_info(location);
618+
debug!(?source_info);
619+
let lint_root = source_info.scope.lint_root(&self.body.source_scopes);
620+
debug!(?lint_root);
621+
let Some(lint_root) = lint_root else {
622+
// This happens when the issue is in a function from a foreign crate that
623+
// we monomorphized in the current crate. We can't get a `HirId` for things
624+
// in other crates.
625+
// FIXME: Find out where to report the lint on. Maybe simply crate-level lint root
626+
// but correct span? This would make the lint at least accept crate-level lint attributes.
627+
return;
628+
};
629+
self.tcx.emit_spanned_lint(
630+
LARGE_ASSIGNMENTS,
631+
lint_root,
632+
source_info.span,
633+
LargeAssignmentsLint {
634+
span: source_info.span,
635+
size: layout.size.bytes(),
636+
limit: limit.bytes(),
637+
},
638+
);
640639
}
641640
}
642641

0 commit comments

Comments
 (0)