Skip to content

Commit

Permalink
More tests for large_enum_variant
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Dec 15, 2024
1 parent 60dbda2 commit 42a0263
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/ui/large_enum_variant.64bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,21 @@ help: consider boxing the large fields to reduce the total size of the enum
LL | Error(Box<PossiblyLargeEnumWithConst<256>>),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 16 previous errors
error: large size difference between variants
--> tests/ui/large_enum_variant.rs:158:1
|
LL | / enum WithRecursion {
LL | | Large([u64; 64]),
| | ---------------- the largest variant contains at least 512 bytes
LL | | Recursive(Box<WithRecursion>),
| | ----------------------------- the second-largest variant contains at least 0 bytes
LL | | }
| |_^ the entire enum is at least 0 bytes
|
help: consider boxing the large fields to reduce the total size of the enum
|
LL | Large(Box<[u64; 64]>),
| ~~~~~~~~~~~~~~

error: aborting due to 17 previous errors

15 changes: 15 additions & 0 deletions tests/ui/large_enum_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ enum LargeEnumOfConst {
Error(PossiblyLargeEnumWithConst<256>),
}

enum WithRecursion {
Large([u64; 64]),
Recursive(Box<WithRecursion>),
}

enum WithRecursionAndGenerics<T> {
Large([T; 64]),
Recursive(Box<WithRecursionAndGenerics<T>>),
}

enum LargeEnumWithGenericsAndRecursive {
Ok(),
Error(WithRecursionAndGenerics<u64>),
}

fn main() {
external!(
enum LargeEnumInMacro {
Expand Down

0 comments on commit 42a0263

Please sign in to comment.