Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/parser.rs')
-rw-r--r--crates/mbe/src/parser.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs
index 9be8d7085d..6c7be59841 100644
--- a/crates/mbe/src/parser.rs
+++ b/crates/mbe/src/parser.rs
@@ -135,6 +135,14 @@ fn next_op<'a>(first: &tt::TokenTree, src: &mut TtIter<'a>, mode: Mode) -> Resul
let id = lit.id;
Op::Var { name, kind, id }
}
+ tt::Leaf::Punct(punct @ tt::Punct { char: '$', .. }) => match mode {
+ Mode::Pattern => {
+ return Err(ParseError::unexpected(
+ "`$$` is not allowed on the pattern side",
+ ))
+ }
+ Mode::Template => Op::Leaf(tt::Leaf::Punct(*punct)),
+ },
tt::Leaf::Punct(_) | tt::Leaf::Literal(_) => {
return Err(ParseError::expected("expected ident"))
}