Skip to content

Commit 81099c2

Browse files
committed
VariantSizeDifferences: bail on SizeOverflow
1 parent 5da2e53 commit 81099c2

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/librustc_lint/types.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -998,10 +998,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
998998
let ty = cx.tcx.erase_regions(&t);
999999
let layout = match cx.layout_of(ty) {
10001000
Ok(layout) => layout,
1001-
Err(ty::layout::LayoutError::Unknown(_)) => return,
1002-
Err(err @ ty::layout::LayoutError::SizeOverflow(_)) => {
1003-
bug!("failed to get layout for `{}`: {}", t, err);
1004-
}
1001+
Err(ty::layout::LayoutError::Unknown(_))
1002+
| Err(ty::layout::LayoutError::SizeOverflow(_)) => return,
10051003
};
10061004
let (variants, tag) = match layout.variants {
10071005
layout::Variants::Multiple {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// build-fail
2+
// only-x86_64
3+
4+
fn main() {
5+
Bug::V([0; !0]); //~ ERROR is too big for the current
6+
}
7+
8+
enum Bug {
9+
V([u8; !0]),
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: the type `[u8; 18446744073709551615]` is too big for the current architecture
2+
--> $DIR/issue-69485-var-size-diffs-too-large.rs:5:12
3+
|
4+
LL | Bug::V([0; !0]);
5+
| ^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)