diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-08-31 13:46:51 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-10-25 16:47:35 +0200 |
| commit | 73e2b4662d32f517f8cb874e45f48c2a05a81456 (patch) | |
| tree | 06283616359cbede9998435d4e2dbbca6b3ac9f6 | |
| parent | 0f970486183084634b08f516531c55d2286a38af (diff) | |
Prepare miri for unsized locals
| -rw-r--r-- | src/librustc_mir/interpret/place.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index a4bb15662d8..b7bc4867307 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -880,9 +880,16 @@ where layout: TyLayout<'tcx>, kind: MemoryKind<M::MemoryKinds>, ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { - assert!(!layout.is_unsized(), "cannot alloc memory for unsized type"); - let ptr = self.memory.allocate(layout.size, layout.align, kind)?; - Ok(MPlaceTy::from_aligned_ptr(ptr, layout)) + if layout.is_unsized() { + assert!(self.tcx.features().unsized_locals, "cannot alloc memory for unsized type"); + // allocate a fat pointer slot instead + let fat = self.tcx.mk_mut_ptr(layout.ty); + let fat = self.layout_of(fat)?; + self.allocate(fat, kind) + } else { + let ptr = self.memory.allocate(layout.size, layout.align, kind)?; + Ok(MPlaceTy::from_aligned_ptr(ptr, layout)) + } } pub fn write_discriminant_index( |
