aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-03 17:07:27 +0000
committerGitHub <[email protected]>2020-03-03 17:07:27 +0000
commitcebb995d21e18990939287f55628237563583b27 (patch)
tree1285b0bc44128ed92f454f98be039c5e80d840de /crates/ra_hir_expand
parent674770ef0473cf938d734f54bcf33524d9fdf5f8 (diff)
parent3dc3d9d18fba0396afa73644865c687b2e64815e (diff)
Merge #3425
3425: Fix a bug for single dollar sign macro r=matklad a=edwin0cheng This PR fixed a bug to allow the following valid `macro_rules!` : ```rust macro_rules! m { ($) => ($) } ``` Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/db.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index af5b22d1c..70d969238 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -86,10 +86,13 @@ pub(crate) fn macro_def(
86 log::warn!("fail on macro_def to token tree: {:#?}", arg); 86 log::warn!("fail on macro_def to token tree: {:#?}", arg);
87 None 87 None
88 })?; 88 })?;
89 let rules = MacroRules::parse(&tt).ok().or_else(|| { 89 let rules = match MacroRules::parse(&tt) {
90 log::warn!("fail on macro_def parse: {:#?}", tt); 90 Ok(it) => it,
91 None 91 Err(err) => {
92 })?; 92 log::warn!("fail on macro_def parse: error: {:#?} {:#?}", err, tt);
93 return None;
94 }
95 };
93 Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) 96 Some(Arc::new((TokenExpander::MacroRules(rules), tmap)))
94 } 97 }
95 MacroDefKind::BuiltIn(expander) => { 98 MacroDefKind::BuiltIn(expander) => {
@@ -150,7 +153,9 @@ pub(crate) fn parse_macro(
150 // Note: 153 // Note:
151 // The final goal we would like to make all parse_macro success, 154 // The final goal we would like to make all parse_macro success,
152 // such that the following log will not call anyway. 155 // such that the following log will not call anyway.
153 log::warn!("fail on macro_parse: (reason: {})", err,); 156 let loc: MacroCallLoc = db.lookup_intern_macro(macro_call_id);
157 let node = loc.kind.node(db);
158 log::warn!("fail on macro_parse: (reason: {} macro_call: {:#})", err, node.value);
154 }) 159 })
155 .ok()?; 160 .ok()?;
156 161