Skip to content

Commit 873bfb7

Browse files
committed
Parse arbitrary struct reprs
1 parent 2fcc137 commit 873bfb7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

chalk-parse/src/parser.lalrpop

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ WellKnownTrait: WellKnownTrait = {
5959
"#" "[" "lang" "(" "unsize" ")" "]" => WellKnownTrait::Unsize,
6060
};
6161

62-
StructReprC: () = "#" "[" "repr(C)" "]";
63-
StructReprPacked: () = "#" "[" "repr(packed)" "]";
62+
StructRepr: Atom = "#" "[" "repr" "(" <name:Id> ")" "]" => name.str;
6463

6564
StructDefn: StructDefn = {
66-
<upstream:UpstreamKeyword?> <fundamental:FundamentalKeyword?> <phantom_data:PhantomDataKeyword?> <repr_c:StructReprC?> <repr_packed:StructReprPacked?>
65+
<upstream:UpstreamKeyword?> <fundamental:FundamentalKeyword?> <phantom_data:PhantomDataKeyword?> <repr:StructRepr*>
6766
"struct" <n:Id><p:Angle<VariableKind>>
6867
<w:QuantifiedWhereClauses> "{" <f:Fields> "}" => StructDefn
6968
{
@@ -77,8 +76,8 @@ StructDefn: StructDefn = {
7776
phantom_data: phantom_data.is_some(),
7877
},
7978
repr: StructRepr {
80-
repr_c: repr_c.is_some(),
81-
repr_packed: repr_packed.is_some(),
79+
repr_c: repr.iter().any(|s| s == "C"),
80+
repr_packed: repr.iter().any(|s| s == "packed"),
8281
},
8382
}
8483
};

0 commit comments

Comments
 (0)