From dfab545d5df974d4a50325695a25f763b7613baf Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 24 Apr 2019 03:00:59 +0800 Subject: [PATCH] Add more information on macro rules fail to parse --- crates/ra_hir/src/ids.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index c7849c995b0..b0e9b1f9af7 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -128,8 +128,14 @@ fn from(macro_call_id: MacroCallId) -> HirFileId { pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option> { let macro_call = id.0.to_node(db); let arg = macro_call.token_tree()?; - let (tt, _) = mbe::ast_to_token_tree(arg)?; - let rules = MacroRules::parse(&tt).ok()?; + let (tt, _) = mbe::ast_to_token_tree(arg).or_else(|| { + log::warn!("fail on macro_def to token tree: {:#?}", arg); + None + })?; + let rules = MacroRules::parse(&tt).ok().or_else(|| { + log::warn!("fail on macro_def parse: {:#?}", tt); + None + })?; Some(Arc::new(rules)) }