diff options
author | Edwin Cheng <[email protected]> | 2019-04-23 20:00:59 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-25 19:03:55 +0100 |
commit | dfab545d5df974d4a50325695a25f763b7613baf (patch) | |
tree | 09606318228a971f4035d1b1d17f0576d15165c7 | |
parent | e4e2338f97d734624fb21b7972c73288ca04e65e (diff) |
Add more information on macro rules fail to parse
-rw-r--r-- | crates/ra_hir/src/ids.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index c7849c995..b0e9b1f9a 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -128,8 +128,14 @@ pub struct MacroDefId(pub(crate) AstId<ast::MacroCall>); | |||
128 | pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { | 128 | pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { |
129 | let macro_call = id.0.to_node(db); | 129 | let macro_call = id.0.to_node(db); |
130 | let arg = macro_call.token_tree()?; | 130 | let arg = macro_call.token_tree()?; |
131 | let (tt, _) = mbe::ast_to_token_tree(arg)?; | 131 | let (tt, _) = mbe::ast_to_token_tree(arg).or_else(|| { |
132 | let rules = MacroRules::parse(&tt).ok()?; | 132 | log::warn!("fail on macro_def to token tree: {:#?}", arg); |
133 | None | ||
134 | })?; | ||
135 | let rules = MacroRules::parse(&tt).ok().or_else(|| { | ||
136 | log::warn!("fail on macro_def parse: {:#?}", tt); | ||
137 | None | ||
138 | })?; | ||
133 | Some(Arc::new(rules)) | 139 | Some(Arc::new(rules)) |
134 | } | 140 | } |
135 | 141 | ||