1
- //! Removes assignments to ZST places.
1
+ //! Removes operations on ZST places, and convert ZST operands to constants .
2
2
3
3
use crate :: MirPass ;
4
4
use rustc_middle:: mir:: interpret:: ConstValue ;
@@ -53,7 +53,7 @@ fn maybe_zst(ty: Ty<'_>) -> bool {
53
53
}
54
54
55
55
impl < ' tcx > Replacer < ' _ , ' tcx > {
56
- fn is_zst ( & self , ty : Ty < ' tcx > ) -> bool {
56
+ fn known_to_be_zst ( & self , ty : Ty < ' tcx > ) -> bool {
57
57
if !maybe_zst ( ty) {
58
58
return false ;
59
59
}
@@ -64,7 +64,7 @@ impl<'tcx> Replacer<'_, 'tcx> {
64
64
}
65
65
66
66
fn make_zst ( & self , ty : Ty < ' tcx > ) -> Constant < ' tcx > {
67
- debug_assert ! ( self . is_zst ( ty) ) ;
67
+ debug_assert ! ( self . known_to_be_zst ( ty) ) ;
68
68
Constant {
69
69
span : rustc_span:: DUMMY_SP ,
70
70
user_ty : None ,
@@ -83,12 +83,12 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
83
83
VarDebugInfoContents :: Const ( _) => { }
84
84
VarDebugInfoContents :: Place ( place) => {
85
85
let place_ty = place. ty ( self . local_decls , self . tcx ) . ty ;
86
- if self . is_zst ( place_ty) {
86
+ if self . known_to_be_zst ( place_ty) {
87
87
var_debug_info. value = VarDebugInfoContents :: Const ( self . make_zst ( place_ty) )
88
88
}
89
89
}
90
90
VarDebugInfoContents :: Composite { ty, fragments : _ } => {
91
- if self . is_zst ( ty) {
91
+ if self . known_to_be_zst ( ty) {
92
92
var_debug_info. value = VarDebugInfoContents :: Const ( self . make_zst ( ty) )
93
93
}
94
94
}
@@ -100,7 +100,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
100
100
return ;
101
101
}
102
102
let op_ty = operand. ty ( self . local_decls , self . tcx ) ;
103
- if self . is_zst ( op_ty)
103
+ if self . known_to_be_zst ( op_ty)
104
104
&& self . tcx . consider_optimizing ( || {
105
105
format ! ( "RemoveZsts - Operand: {:?} Location: {:?}" , operand, loc)
106
106
} )
@@ -114,7 +114,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
114
114
statement. kind
115
115
{
116
116
let place_ty = place. ty ( self . local_decls , self . tcx ) . ty ;
117
- if self . is_zst ( place_ty)
117
+ if self . known_to_be_zst ( place_ty)
118
118
&& self . tcx . consider_optimizing ( || {
119
119
format ! (
120
120
"RemoveZsts - Place: {:?} SourceInfo: {:?}" ,
0 commit comments