@@ -4,6 +4,7 @@ use rustc_ast::{AnonConst, DUMMY_NODE_ID, Ty, TyPat, TyPatKind, ast, token};
4
4
use rustc_errors:: PResult ;
5
5
use rustc_expand:: base:: { self , DummyResult , ExpandResult , ExtCtxt , MacroExpanderResult } ;
6
6
use rustc_parse:: exp;
7
+ use rustc_parse:: parser:: { CommaRecoveryMode , RecoverColon , RecoverComma } ;
7
8
use rustc_span:: Span ;
8
9
9
10
pub ( crate ) fn expand < ' cx > (
@@ -27,7 +28,17 @@ fn parse_pat_ty<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P
27
28
let ty = parser. parse_ty ( ) ?;
28
29
parser. expect_keyword ( exp ! ( Is ) ) ?;
29
30
30
- let pat = pat_to_ty_pat ( cx, parser. parse_pat_no_top_alt ( None , None ) ?. into_inner ( ) ) ;
31
+ let pat = pat_to_ty_pat (
32
+ cx,
33
+ parser
34
+ . parse_pat_no_top_guard (
35
+ None ,
36
+ RecoverComma :: No ,
37
+ RecoverColon :: No ,
38
+ CommaRecoveryMode :: EitherTupleOrPipe ,
39
+ ) ?
40
+ . into_inner ( ) ,
41
+ ) ;
31
42
32
43
if parser. token != token:: Eof {
33
44
parser. unexpected ( ) ?;
@@ -47,6 +58,9 @@ fn pat_to_ty_pat(cx: &mut ExtCtxt<'_>, pat: ast::Pat) -> P<TyPat> {
47
58
end. map ( |value| P ( AnonConst { id : DUMMY_NODE_ID , value } ) ) ,
48
59
include_end,
49
60
) ,
61
+ ast:: PatKind :: Or ( variants) => TyPatKind :: Or (
62
+ variants. into_iter ( ) . map ( |pat| pat_to_ty_pat ( cx, pat. into_inner ( ) ) ) . collect ( ) ,
63
+ ) ,
50
64
ast:: PatKind :: Err ( guar) => TyPatKind :: Err ( guar) ,
51
65
_ => TyPatKind :: Err ( cx. dcx ( ) . span_err ( pat. span , "pattern not supported in pattern types" ) ) ,
52
66
} ;
0 commit comments