@@ -281,19 +281,22 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
281
281
}
282
282
283
283
fn check_lhs_nt_follows ( cx : & mut ExtCtxt , lhs : & NamedMatch , sp : Span ) {
284
- // lhs is going to be like MatchedNonterminal(NtTT(TtDelimited(...))), where
285
- // the entire lhs is those tts.
286
- // if ever we get box/deref patterns, this could turn into an `if let
287
- // &MatchedNonterminal(NtTT(box TtDelimited(...))) = lhs`
288
- let matcher = match lhs {
284
+ // lhs is going to be like MatchedNonterminal(NtTT(TtDelimited(...))), where the entire lhs is
285
+ // those tts. Or, it can be a "bare sequence", not wrapped in parens.
286
+ match lhs {
289
287
& MatchedNonterminal ( NtTT ( ref inner) ) => match & * * inner {
290
- & TtDelimited ( _, ref tts) => tts. tts . as_slice ( ) ,
291
- _ => cx. span_bug ( sp, "wrong-structured lhs for follow check" )
288
+ & TtDelimited ( _, ref tts) => {
289
+ check_matcher ( cx, tts. tts . iter ( ) , & Eof ) ;
290
+ } ,
291
+ tt @ & TtSequence ( ..) => {
292
+ check_matcher ( cx, Some ( tt) . into_iter ( ) , & Eof ) ;
293
+ } ,
294
+ _ => cx. span_bug ( sp, "wrong-structured lhs for follow check (didn't find \
295
+ a TtDelimited or TtSequence)")
292
296
} ,
293
- _ => cx. span_bug ( sp, "wrong-structured lhs for follow check" )
297
+ _ => cx. span_bug ( sp, "wrong-structured lhs for follow check (didn't find a \
298
+ MatchedNonterminal)")
294
299
} ;
295
-
296
- check_matcher ( cx, matcher. iter ( ) , & Eof ) ;
297
300
// we don't abort on errors on rejection, the driver will do that for us
298
301
// after parsing/expansion. we can report every error in every macro this way.
299
302
}
0 commit comments