@@ -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 > (
@@ -33,7 +34,17 @@ fn parse_pat_ty<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P
33
34
let span = start. to ( parser. token . span ) ;
34
35
ty_pat ( TyPatKind :: NotNull , span)
35
36
} else {
36
- pat_to_ty_pat ( cx, parser. parse_pat_no_top_alt ( None , None ) ?. into_inner ( ) )
37
+ pat_to_ty_pat (
38
+ cx,
39
+ parser
40
+ . parse_pat_no_top_guard (
41
+ None ,
42
+ RecoverComma :: No ,
43
+ RecoverColon :: No ,
44
+ CommaRecoveryMode :: EitherTupleOrPipe ,
45
+ ) ?
46
+ . into_inner ( ) ,
47
+ )
37
48
} ;
38
49
39
50
if parser. token != token:: Eof {
@@ -53,6 +64,9 @@ fn pat_to_ty_pat(cx: &mut ExtCtxt<'_>, pat: ast::Pat) -> P<TyPat> {
53
64
end. map ( |value| P ( AnonConst { id : DUMMY_NODE_ID , value } ) ) ,
54
65
include_end,
55
66
) ,
67
+ ast:: PatKind :: Or ( variants) => TyPatKind :: Or (
68
+ variants. into_iter ( ) . map ( |pat| pat_to_ty_pat ( cx, pat. into_inner ( ) ) ) . collect ( ) ,
69
+ ) ,
56
70
ast:: PatKind :: Err ( guar) => TyPatKind :: Err ( guar) ,
57
71
_ => TyPatKind :: Err ( cx. dcx ( ) . span_err ( pat. span , "pattern not supported in pattern types" ) ) ,
58
72
} ;
0 commit comments