minor, move

This commit is contained in:
Aleksey Kladov 2019-05-04 17:42:24 +03:00
parent 5dc384132f
commit 87a1e276d5

View File

@ -81,25 +81,6 @@ impl HirFileId {
}
}
fn parse_macro(
db: &impl DefDatabase,
macro_call_id: MacroCallId,
) -> Result<TreeArc<SourceFile>, 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(&macro_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<TreeArc<SourceFile>, 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(&macro_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 {