Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/benchmark.rs')
| -rw-r--r-- | crates/mbe/src/benchmark.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs index b185556b5c..ffe3bdd06c 100644 --- a/crates/mbe/src/benchmark.rs +++ b/crates/mbe/src/benchmark.rs @@ -2,7 +2,7 @@ use intern::Symbol; use rustc_hash::FxHashMap; -use span::{Edition, Span}; +use span::Span; use stdx::itertools::Itertools; use syntax::{ AstNode, @@ -16,7 +16,7 @@ use syntax_bridge::{ use test_utils::{bench, bench_fixture, skip_slow_tests}; use crate::{ - DeclarativeMacro, + DeclarativeMacro, MacroCallStyle, parser::{MetaVarKind, Op, RepeatKind, Separator}, }; @@ -44,15 +44,16 @@ fn benchmark_expand_macro_rules() { if skip_slow_tests() { return; } + let db = salsa::DatabaseImpl::default(); let rules = macro_rules_fixtures(); - let invocations = invocation_fixtures(&rules); + let invocations = invocation_fixtures(&db, &rules); let hash: usize = { let _pt = bench("mbe expand macro rules"); invocations .into_iter() .map(|(id, tt)| { - let res = rules[&id].expand(&tt, |_| (), DUMMY, Edition::CURRENT); + let res = rules[&id].expand(&db, &tt, |_| (), MacroCallStyle::FnLike, DUMMY); assert!(res.err.is_none()); res.value.0.0.len() }) @@ -92,6 +93,7 @@ fn macro_rules_fixtures_tt() -> FxHashMap<String, tt::TopSubtree<Span>> { /// Generate random invocation fixtures from rules fn invocation_fixtures( + db: &dyn salsa::Database, rules: &FxHashMap<String, DeclarativeMacro>, ) -> Vec<(String, tt::TopSubtree<Span>)> { let mut seed = 123456789; @@ -123,7 +125,8 @@ fn invocation_fixtures( } let subtree = builder.build(); - if it.expand(&subtree, |_| (), DUMMY, Edition::CURRENT).err.is_none() { + if it.expand(db, &subtree, |_| (), MacroCallStyle::FnLike, DUMMY).err.is_none() + { res.push((name.clone(), subtree)); break; } |