Skip to content

Commit c2b663c

Browse files
committed
Fix unwrapping usize issue with transparent MaybeUnit array wrapper
1 parent 7e92607 commit c2b663c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/librustc/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
549549
}
550550
}
551551

552+
let count = count.assert_usize(tcx).ok_or(LayoutError::Unknown(ty))?;
552553
let element = self.layout_of(element)?;
553-
let count = count.unwrap_usize(tcx);
554554
let size = element.size.checked_mul(count, dl)
555555
.ok_or(LayoutError::SizeOverflow(ty))?;
556556

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// run-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
use std::mem::MaybeUninit;
7+
8+
#[repr(transparent)]
9+
pub struct MaybeUninitWrapper<const N: usize>(MaybeUninit<[u64; N]>);
10+
11+
fn main() {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/transparent-maybeunit-array-wrapper.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+

0 commit comments

Comments
 (0)