Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 96918a4

Browse files
committed
Prevent pattern type macro invocations from having trailing tokens
1 parent 21079f5 commit 96918a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/rustc_builtin_macros/src/pattern_type.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast::ptr::P;
22
use rustc_ast::tokenstream::TokenStream;
3-
use rustc_ast::{AnonConst, DUMMY_NODE_ID, Ty, TyPat, TyPatKind, ast};
3+
use rustc_ast::{AnonConst, DUMMY_NODE_ID, Ty, TyPat, TyPatKind, ast, token};
44
use rustc_errors::PResult;
55
use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
66
use rustc_parse::exp;
@@ -40,5 +40,9 @@ fn parse_pat_ty<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P
4040

4141
let pat = P(TyPat { id: pat.id, kind, span: pat.span, tokens: pat.tokens });
4242

43+
if parser.token != token::Eof {
44+
parser.unexpected()?;
45+
}
46+
4347
Ok((ty, pat))
4448
}

0 commit comments

Comments
 (0)