rustc_monomorphize: Reduce check_move_size() indentation
This commit is contained in:
parent
af86069ab1
commit
1f56ff8f26
1 changed files with 26 additions and 27 deletions
|
@ -609,34 +609,33 @@ impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> {
|
||||||
let limit = Size::from_bytes(limit);
|
let limit = Size::from_bytes(limit);
|
||||||
let ty = operand.ty(self.body, self.tcx);
|
let ty = operand.ty(self.body, self.tcx);
|
||||||
let ty = self.monomorphize(ty);
|
let ty = self.monomorphize(ty);
|
||||||
let layout = self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty));
|
let Ok(layout) = self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)) else { return };
|
||||||
if let Ok(layout) = layout {
|
if layout.size <= limit {
|
||||||
if layout.size > limit {
|
return;
|
||||||
debug!(?layout);
|
|
||||||
let source_info = self.body.source_info(location);
|
|
||||||
debug!(?source_info);
|
|
||||||
let lint_root = source_info.scope.lint_root(&self.body.source_scopes);
|
|
||||||
debug!(?lint_root);
|
|
||||||
let Some(lint_root) = lint_root else {
|
|
||||||
// This happens when the issue is in a function from a foreign crate that
|
|
||||||
// we monomorphized in the current crate. We can't get a `HirId` for things
|
|
||||||
// in other crates.
|
|
||||||
// FIXME: Find out where to report the lint on. Maybe simply crate-level lint root
|
|
||||||
// but correct span? This would make the lint at least accept crate-level lint attributes.
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
self.tcx.emit_spanned_lint(
|
|
||||||
LARGE_ASSIGNMENTS,
|
|
||||||
lint_root,
|
|
||||||
source_info.span,
|
|
||||||
LargeAssignmentsLint {
|
|
||||||
span: source_info.span,
|
|
||||||
size: layout.size.bytes(),
|
|
||||||
limit: limit.bytes(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
debug!(?layout);
|
||||||
|
let source_info = self.body.source_info(location);
|
||||||
|
debug!(?source_info);
|
||||||
|
let lint_root = source_info.scope.lint_root(&self.body.source_scopes);
|
||||||
|
debug!(?lint_root);
|
||||||
|
let Some(lint_root) = lint_root else {
|
||||||
|
// This happens when the issue is in a function from a foreign crate that
|
||||||
|
// we monomorphized in the current crate. We can't get a `HirId` for things
|
||||||
|
// in other crates.
|
||||||
|
// FIXME: Find out where to report the lint on. Maybe simply crate-level lint root
|
||||||
|
// but correct span? This would make the lint at least accept crate-level lint attributes.
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
self.tcx.emit_spanned_lint(
|
||||||
|
LARGE_ASSIGNMENTS,
|
||||||
|
lint_root,
|
||||||
|
source_info.span,
|
||||||
|
LargeAssignmentsLint {
|
||||||
|
span: source_info.span,
|
||||||
|
size: layout.size.bytes(),
|
||||||
|
limit: limit.bytes(),
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue