mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Add mbe expand limit and poision macro set
This commit is contained in:
parent
bbc5c1d24e
commit
b177813f3b
5 changed files with 216 additions and 18 deletions
|
@ -94,6 +94,13 @@ fn parse_macro(
|
|||
|
||||
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))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue