Skip to content

Commit

Permalink
Rollup merge of rust-lang#69881 - Centril:fix-69485, r=oli-obk
Browse files Browse the repository at this point in the history
VariantSizeDifferences: bail on SizeOverflow

Fixes rust-lang#69485.

r? @oli-obk
  • Loading branch information
Centril committed Mar 16, 2020
2 parents 1350be7 + 81099c2 commit 79d85fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
let ty = cx.tcx.erase_regions(&t);
let layout = match cx.layout_of(ty) {
Ok(layout) => layout,
Err(ty::layout::LayoutError::Unknown(_)) => return,
Err(err @ ty::layout::LayoutError::SizeOverflow(_)) => {
bug!("failed to get layout for `{}`: {}", t, err);
}
Err(ty::layout::LayoutError::Unknown(_))
| Err(ty::layout::LayoutError::SizeOverflow(_)) => return,
};
let (variants, tag) = match layout.variants {
layout::Variants::Multiple {
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// build-fail
// only-x86_64

fn main() {
Bug::V([0; !0]); //~ ERROR is too big for the current
}

enum Bug {
V([u8; !0]),
}
8 changes: 8 additions & 0 deletions src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: the type `[u8; 18446744073709551615]` is too big for the current architecture
--> $DIR/issue-69485-var-size-diffs-too-large.rs:5:12
|
LL | Bug::V([0; !0]);
| ^^^^^^^

error: aborting due to previous error

0 comments on commit 79d85fb

Please sign in to comment.