From 87a1e276d56a3cb5f9d9c59f8c52c5573e19982b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 4 May 2019 17:42:24 +0300 Subject: minor, move --- crates/ra_hir/src/ids.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 24c5f412b..cf0e934a9 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -81,25 +81,6 @@ impl HirFileId { } } -fn parse_macro( - db: &impl DefDatabase, - macro_call_id: MacroCallId, -) -> Result, String> { - let loc = macro_call_id.loc(db); - let macro_arg = db.macro_arg(macro_call_id).ok_or("Fail to args in to tt::TokenTree")?; - - let macro_rules = db.macro_def(loc.def).ok_or("Fail to find macro definition")?; - let tt = macro_rules.expand(¯o_arg).map_err(|err| format!("{:?}", err))?; - - // Set a hard limit for the expanded tt - let count = tt.count(); - if count > 65536 { - return Err(format!("Total tokens count exceed limit : count = {}", count)); - } - - Ok(mbe::token_tree_to_ast_item_list(&tt)) -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] enum HirFileIdRepr { File(FileId), @@ -143,6 +124,25 @@ pub(crate) fn macro_arg_query(db: &impl DefDatabase, id: MacroCallId) -> Option< Some(Arc::new(tt)) } +fn parse_macro( + db: &impl DefDatabase, + macro_call_id: MacroCallId, +) -> Result, String> { + let loc = macro_call_id.loc(db); + let macro_arg = db.macro_arg(macro_call_id).ok_or("Fail to args in to tt::TokenTree")?; + + let macro_rules = db.macro_def(loc.def).ok_or("Fail to find macro definition")?; + let tt = macro_rules.expand(¯o_arg).map_err(|err| format!("{:?}", err))?; + + // Set a hard limit for the expanded tt + let count = tt.count(); + if count > 65536 { + return Err(format!("Total tokens count exceed limit : count = {}", count)); + } + + Ok(mbe::token_tree_to_ast_item_list(&tt)) +} + macro_rules! impl_intern_key { ($name:ident) => { impl salsa::InternKey for $name { -- cgit v1.2.3