diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-12-21 15:08:33 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-12-21 15:08:33 +0100 |
| commit | 0eacf2cb240606343284a2d38b0f54b6028b134d (patch) | |
| tree | 09eb58191438bed47e99af96d07788a6b92f611c /src | |
| parent | 6d34ec18c7d7e574553f6347ecf08e1e1c45c13d (diff) | |
| download | rust-0eacf2cb240606343284a2d38b0f54b6028b134d.tar.gz rust-0eacf2cb240606343284a2d38b0f54b6028b134d.zip | |
Sidestep ICE in `FieldPlacement::count` by not calling it when count will not fit in host's usize.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/layout.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index f4506c8e819..2bc352d1d99 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1852,7 +1852,11 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { return Ok(None); } } - if let FieldPlacement::Array { .. } = layout.fields { + if let FieldPlacement::Array { count: original_64_bit_count, .. } = layout.fields { + // rust-lang/rust#57038: avoid ICE within FieldPlacement::count when count too big + if original_64_bit_count > usize::max_value() as u64 { + return Err(LayoutError::SizeOverflow(layout.ty)); + } if layout.fields.count() > 0 { return self.find_niche(layout.field(self, 0)?); } else { |
