File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,8 @@ testcases![
199
199
Bar : { "a" field: "b" ? } |
200
200
Baz : { baz: "ab" } ;
201
201
} :
202
+ A ( "a" ) => "\
203
+ 1:1-1:2 => A::Bar",
202
204
A ( "ab" ) => "\
203
205
1:1-1:3 => A::Foo(
204
206
1:1-1:3,
Original file line number Diff line number Diff line change @@ -230,8 +230,16 @@ impl<Pat: RustInputPat> RuleWithFieldsMethods<Pat> for RuleWithFields {
230
230
let children = match & cx[ self . fields ] {
231
231
Fields :: Leaf ( None ) => return quote ! ( _) ,
232
232
Fields :: Leaf ( Some ( field) ) => {
233
- let ( i, _, _) = rust_fields. get_full ( & field. name ) . unwrap ( ) ;
234
- return quote ! ( #i) ;
233
+ let ( i, _, rust_field) = rust_fields. get_full ( & field. name ) . unwrap ( ) ;
234
+
235
+ // HACK(eddyb) account for the fact that `x:X?` is `x:{X?}`.
236
+ let shape = quote ! ( #i) ;
237
+ if let Rule :: Opt ( _) = cx[ self . rule ] {
238
+ if rust_field. refutable {
239
+ return quote ! ( [ #shape] ) ;
240
+ }
241
+ }
242
+ return shape;
235
243
}
236
244
Fields :: Aggregate ( children) => children,
237
245
} ;
You can’t perform that action at this time.
0 commit comments