mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
feat: Support $$
in macros.
The implementation mirrors what `rustc` currently does [1]. Part of #11952.
[1]: 0595ea1d12/compiler/rustc_expand/src/mbe/quoted.rs (L230-L241)
This commit is contained in:
parent
e25cbf8584
commit
40bfb29e50
3 changed files with 82 additions and 0 deletions
|
@ -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"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue