diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-10-13 12:27:45 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-10-13 14:39:57 -0700 |
| commit | 8fd16baa57aafd4959bda052dad261da997e6862 (patch) | |
| tree | 6079f8df69633ac689f70e61686972d845571d7f /src/librustc_mir/dataflow | |
| parent | 061b906683eccd01b59f848a7941f3fd7aff8b00 (diff) | |
| download | rust-8fd16baa57aafd4959bda052dad261da997e6862.tar.gz rust-8fd16baa57aafd4959bda052dad261da997e6862.zip | |
Remove special case for zero-sized arrays from indirectly mut locals
Diffstat (limited to 'src/librustc_mir/dataflow')
| -rw-r--r-- | src/librustc_mir/dataflow/impls/indirect_mutation.rs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/librustc_mir/dataflow/impls/indirect_mutation.rs b/src/librustc_mir/dataflow/impls/indirect_mutation.rs index 990425c3252..bc09e327179 100644 --- a/src/librustc_mir/dataflow/impls/indirect_mutation.rs +++ b/src/librustc_mir/dataflow/impls/indirect_mutation.rs @@ -104,25 +104,16 @@ impl<'tcx> TransferFunction<'_, '_, 'tcx> { kind: mir::BorrowKind, borrowed_place: &mir::Place<'tcx>, ) -> bool { - let borrowed_ty = borrowed_place.ty(self.body, self.tcx).ty; - - // Zero-sized types cannot be mutated, since there is nothing inside to mutate. - // - // FIXME: For now, we only exempt arrays of length zero. We need to carefully - // consider the effects before extending this to all ZSTs. - if let ty::Array(_, len) = borrowed_ty.kind { - if len.try_eval_usize(self.tcx, self.param_env) == Some(0) { - return false; - } - } - match kind { mir::BorrowKind::Mut { .. } => true, | mir::BorrowKind::Shared | mir::BorrowKind::Shallow | mir::BorrowKind::Unique - => !borrowed_ty.is_freeze(self.tcx, self.param_env, DUMMY_SP), + => !borrowed_place + .ty(self.body, self.tcx) + .ty + .is_freeze(self.tcx, self.param_env, DUMMY_SP), } } } |
