aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/mbe_expander
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-08 06:03:54 +0000
committerGitHub <[email protected]>2021-01-08 06:03:54 +0000
commitbe02ac981de88869a9d6069b675a78a2e9e31f99 (patch)
treecfdfe11e7d4d6b50350679ab6cff67bd64dd90a4 /crates/mbe/src/mbe_expander
parent1a29934c37cf4ffa2b269c39a25245e58d3916d5 (diff)
parentbced02c5dc636c7b88aeadf9eefa66f8cf06103e (diff)
Merge #7205
7205: Fix bug for $crate in LHS of mbe r=edwin0cheng a=edwin0cheng We treated `$crate` as meta variable in LHS of mbe, which should be an `ident`. Fixes #7204 Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/mbe/src/mbe_expander')
-rw-r--r--crates/mbe/src/mbe_expander/transcriber.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/crates/mbe/src/mbe_expander/transcriber.rs b/crates/mbe/src/mbe_expander/transcriber.rs
index 57f3f104d..27b2ac777 100644
--- a/crates/mbe/src/mbe_expander/transcriber.rs
+++ b/crates/mbe/src/mbe_expander/transcriber.rs
@@ -119,11 +119,10 @@ fn expand_subtree(
119} 119}
120 120
121fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr, id: tt::TokenId) -> ExpandResult<Fragment> { 121fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr, id: tt::TokenId) -> ExpandResult<Fragment> {
122 if v == "crate" { 122 // We already handle $crate case in mbe parser
123 // We simply produce identifier `$crate` here. And it will be resolved when lowering ast to Path. 123 debug_assert!(v != "crate");
124 let tt = tt::Leaf::from(tt::Ident { text: "$crate".into(), id }).into(); 124
125 ExpandResult::ok(Fragment::Tokens(tt)) 125 if !ctx.bindings.contains(v) {
126 } else if !ctx.bindings.contains(v) {
127 // Note that it is possible to have a `$var` inside a macro which is not bound. 126 // Note that it is possible to have a `$var` inside a macro which is not bound.
128 // For example: 127 // For example:
129 // ``` 128 // ```