mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
minor, move
This commit is contained in:
parent
5dc384132f
commit
87a1e276d5
1 changed files with 19 additions and 19 deletions
|
@ -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(¯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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
enum HirFileIdRepr {
|
enum HirFileIdRepr {
|
||||||
File(FileId),
|
File(FileId),
|
||||||
|
@ -143,6 +124,25 @@ pub(crate) fn macro_arg_query(db: &impl DefDatabase, id: MacroCallId) -> Option<
|
||||||
Some(Arc::new(tt))
|
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(¯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 {
|
macro_rules! impl_intern_key {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
impl salsa::InternKey for $name {
|
impl salsa::InternKey for $name {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue