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