Rename method.

This commit is contained in:
Camille GILLOT 2023-01-25 16:54:45 +00:00
parent 9e3f091f2b
commit 63ce733fe2

View File

@ -1,4 +1,4 @@
//! Removes assignments to ZST places. //! Removes operations on ZST places, and convert ZST operands to constants.
use crate::MirPass; use crate::MirPass;
use rustc_middle::mir::interpret::ConstValue; use rustc_middle::mir::interpret::ConstValue;
@ -53,7 +53,7 @@ fn maybe_zst(ty: Ty<'_>) -> bool {
} }
impl<'tcx> Replacer<'_, 'tcx> { impl<'tcx> Replacer<'_, 'tcx> {
fn is_zst(&self, ty: Ty<'tcx>) -> bool { fn known_to_be_zst(&self, ty: Ty<'tcx>) -> bool {
if !maybe_zst(ty) { if !maybe_zst(ty) {
return false; return false;
} }
@ -64,7 +64,7 @@ impl<'tcx> Replacer<'_, 'tcx> {
} }
fn make_zst(&self, ty: Ty<'tcx>) -> Constant<'tcx> { fn make_zst(&self, ty: Ty<'tcx>) -> Constant<'tcx> {
debug_assert!(self.is_zst(ty)); debug_assert!(self.known_to_be_zst(ty));
Constant { Constant {
span: rustc_span::DUMMY_SP, span: rustc_span::DUMMY_SP,
user_ty: None, user_ty: None,
@ -83,12 +83,12 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
VarDebugInfoContents::Const(_) => {} VarDebugInfoContents::Const(_) => {}
VarDebugInfoContents::Place(place) => { VarDebugInfoContents::Place(place) => {
let place_ty = place.ty(self.local_decls, self.tcx).ty; let place_ty = place.ty(self.local_decls, self.tcx).ty;
if self.is_zst(place_ty) { if self.known_to_be_zst(place_ty) {
var_debug_info.value = VarDebugInfoContents::Const(self.make_zst(place_ty)) var_debug_info.value = VarDebugInfoContents::Const(self.make_zst(place_ty))
} }
} }
VarDebugInfoContents::Composite { ty, fragments: _ } => { VarDebugInfoContents::Composite { ty, fragments: _ } => {
if self.is_zst(ty) { if self.known_to_be_zst(ty) {
var_debug_info.value = VarDebugInfoContents::Const(self.make_zst(ty)) var_debug_info.value = VarDebugInfoContents::Const(self.make_zst(ty))
} }
} }
@ -100,7 +100,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
return; return;
} }
let op_ty = operand.ty(self.local_decls, self.tcx); let op_ty = operand.ty(self.local_decls, self.tcx);
if self.is_zst(op_ty) if self.known_to_be_zst(op_ty)
&& self.tcx.consider_optimizing(|| { && self.tcx.consider_optimizing(|| {
format!("RemoveZsts - Operand: {:?} Location: {:?}", operand, loc) format!("RemoveZsts - Operand: {:?} Location: {:?}", operand, loc)
}) })
@ -114,7 +114,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
statement.kind statement.kind
{ {
let place_ty = place.ty(self.local_decls, self.tcx).ty; let place_ty = place.ty(self.local_decls, self.tcx).ty;
if self.is_zst(place_ty) if self.known_to_be_zst(place_ty)
&& self.tcx.consider_optimizing(|| { && self.tcx.consider_optimizing(|| {
format!( format!(
"RemoveZsts - Place: {:?} SourceInfo: {:?}", "RemoveZsts - Place: {:?} SourceInfo: {:?}",