From 74a24adc8ecc8bded9d24ccede171da188696122 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 8 Jan 2021 14:00:16 +0800 Subject: Fix bug when $crate in LHS in mbe --- crates/mbe/src/parser.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/mbe/src/parser.rs') diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs index 77cc739b6..f3047972d 100644 --- a/crates/mbe/src/parser.rs +++ b/crates/mbe/src/parser.rs @@ -109,6 +109,10 @@ fn next_op<'a>(first: &tt::TokenTree, src: &mut TtIter<'a>, mode: Mode) -> Resul let id = punct.id; Op::Var { name, kind, id } } + tt::Leaf::Ident(ident) if ident.text == "crate" => { + // We simply produce identifier `$crate` here. And it will be resolved when lowering ast to Path. + Op::Leaf(tt::Leaf::from(tt::Ident { text: "$crate".into(), id: ident.id })) + } tt::Leaf::Ident(ident) => { let name = ident.text.clone(); let kind = eat_fragment_kind(src, mode)?; -- cgit v1.2.3