mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Add more information on macro rules fail to parse
This commit is contained in:
parent
e4e2338f97
commit
dfab545d5d
1 changed files with 8 additions and 2 deletions
|
@ -128,8 +128,14 @@ pub struct MacroDefId(pub(crate) AstId<ast::MacroCall>);
|
||||||
pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
|
pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
|
||||||
let macro_call = id.0.to_node(db);
|
let macro_call = id.0.to_node(db);
|
||||||
let arg = macro_call.token_tree()?;
|
let arg = macro_call.token_tree()?;
|
||||||
let (tt, _) = mbe::ast_to_token_tree(arg)?;
|
let (tt, _) = mbe::ast_to_token_tree(arg).or_else(|| {
|
||||||
let rules = MacroRules::parse(&tt).ok()?;
|
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))
|
Some(Arc::new(rules))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue