diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-03-11 15:27:35 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-04-28 07:36:59 +0000 |
| commit | 96918a4bd574539974e05985c1c53cbcf0c69b50 (patch) | |
| tree | 524543f4fc9e6fa3eaad0a8d79a59c20f8e788b5 /compiler/rustc_builtin_macros | |
| parent | 21079f53a359d9fc82668d4175d49dafdb600563 (diff) | |
| download | rust-96918a4bd574539974e05985c1c53cbcf0c69b50.tar.gz rust-96918a4bd574539974e05985c1c53cbcf0c69b50.zip | |
Prevent pattern type macro invocations from having trailing tokens
Diffstat (limited to 'compiler/rustc_builtin_macros')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/pattern_type.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_builtin_macros/src/pattern_type.rs b/compiler/rustc_builtin_macros/src/pattern_type.rs index a55c7e962d0..a0b84c4ccf5 100644 --- a/compiler/rustc_builtin_macros/src/pattern_type.rs +++ b/compiler/rustc_builtin_macros/src/pattern_type.rs @@ -1,6 +1,6 @@ use rustc_ast::ptr::P; use rustc_ast::tokenstream::TokenStream; -use rustc_ast::{AnonConst, DUMMY_NODE_ID, Ty, TyPat, TyPatKind, ast}; +use rustc_ast::{AnonConst, DUMMY_NODE_ID, Ty, TyPat, TyPatKind, ast, token}; use rustc_errors::PResult; use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; use rustc_parse::exp; @@ -40,5 +40,9 @@ fn parse_pat_ty<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P let pat = P(TyPat { id: pat.id, kind, span: pat.span, tokens: pat.tokens }); + if parser.token != token::Eof { + parser.unexpected()?; + } + Ok((ty, pat)) } |
