Skip to content

Commit 8fd16ba

Browse files
Remove special case for zero-sized arrays from indirectly mut locals
1 parent 061b906 commit 8fd16ba

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/librustc_mir/dataflow/impls/indirect_mutation.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,16 @@ impl<'tcx> TransferFunction<'_, '_, 'tcx> {
104104
kind: mir::BorrowKind,
105105
borrowed_place: &mir::Place<'tcx>,
106106
) -> bool {
107-
let borrowed_ty = borrowed_place.ty(self.body, self.tcx).ty;
108-
109-
// Zero-sized types cannot be mutated, since there is nothing inside to mutate.
110-
//
111-
// FIXME: For now, we only exempt arrays of length zero. We need to carefully
112-
// consider the effects before extending this to all ZSTs.
113-
if let ty::Array(_, len) = borrowed_ty.kind {
114-
if len.try_eval_usize(self.tcx, self.param_env) == Some(0) {
115-
return false;
116-
}
117-
}
118-
119107
match kind {
120108
mir::BorrowKind::Mut { .. } => true,
121109

122110
| mir::BorrowKind::Shared
123111
| mir::BorrowKind::Shallow
124112
| mir::BorrowKind::Unique
125-
=> !borrowed_ty.is_freeze(self.tcx, self.param_env, DUMMY_SP),
113+
=> !borrowed_place
114+
.ty(self.body, self.tcx)
115+
.ty
116+
.is_freeze(self.tcx, self.param_env, DUMMY_SP),
126117
}
127118
}
128119
}

0 commit comments

Comments
 (0)