@@ -92,7 +92,8 @@ impl<'a, 'tcx> Visitor<'tcx> for NicheFinder<'a, 'tcx> {
92
92
if let Rvalue :: Cast ( CastKind :: Transmute , op, ty) = rvalue {
93
93
if let Some ( niche) = self . get_niche ( * ty) {
94
94
with_no_trimmed_paths ! ( debug!(
95
- "Found place {op:?}: {ty:?} with niche due to Transmute"
95
+ "Found place {op:?}: {ty:?} with niche {niche:?} due to Transmute: {:?}" ,
96
+ self . body. stmt_at( location)
96
97
) ) ;
97
98
self . places . push ( ( op. clone ( ) , niche) ) ;
98
99
}
@@ -114,9 +115,8 @@ impl<'a, 'tcx> Visitor<'tcx> for NicheFinder<'a, 'tcx> {
114
115
}
115
116
116
117
let ty = place. ty ( self . body , self . tcx ) . ty ;
117
- if ty == self . tcx . types . bool {
118
- // LLVM defeats our attempts to insert niche checks for bools by truncating all our
119
- // loads to an i1.
118
+ // bool is actually an i1 to LLVM which means a bool local can never be invalid.
119
+ if ty == self . tcx . types . bool && place. projection . is_empty ( ) {
120
120
return ;
121
121
}
122
122
let Some ( niche) = self . get_niche ( ty) else {
@@ -136,7 +136,8 @@ impl<'a, 'tcx> Visitor<'tcx> for NicheFinder<'a, 'tcx> {
136
136
}
137
137
138
138
with_no_trimmed_paths ! ( debug!(
139
- "Found place {place:?}: {ty:?} with niche due to {context:?}"
139
+ "Found place {place:?}: {ty:?} with niche {niche:?} due to {:?}" ,
140
+ self . body. stmt_at( location)
140
141
) ) ;
141
142
self . places . push ( ( Operand :: Copy ( * place) , niche) ) ;
142
143
@@ -153,6 +154,10 @@ impl<'a, 'tcx> NicheFinder<'a, 'tcx> {
153
154
154
155
let niche = layout. largest_niche ?;
155
156
157
+ if niche. offset == Size :: ZERO {
158
+ return None ;
159
+ }
160
+
156
161
if niche. size ( self . tcx ) == layout. size {
157
162
Some ( NicheKind :: Full ( niche) )
158
163
} else {
@@ -295,7 +300,7 @@ impl<'a, 'tcx> NicheChecker<'a, 'tcx> {
295
300
}
296
301
}
297
302
298
- #[ derive( Clone , Copy ) ]
303
+ #[ derive( Clone , Copy , Debug ) ]
299
304
enum NicheKind {
300
305
Full ( Niche ) ,
301
306
// We need the full Size of the type in order to do the transmute-to-MU approach
0 commit comments