1
1
//! This module add real world mbe example for benchmark tests
2
2
3
3
use rustc_hash:: FxHashMap ;
4
+ use span:: Span ;
4
5
use syntax:: {
5
6
ast:: { self , HasName } ,
6
7
AstNode , SmolStr ,
@@ -9,7 +10,7 @@ use test_utils::{bench, bench_fixture, skip_slow_tests};
9
10
10
11
use crate :: {
11
12
parser:: { MetaVarKind , Op , RepeatKind , Separator } ,
12
- syntax_node_to_token_tree, DeclarativeMacro , DummyTestSpanData , DummyTestSpanMap , DUMMY ,
13
+ syntax_node_to_token_tree, DeclarativeMacro , DummyTestSpanMap , DUMMY ,
13
14
} ;
14
15
15
16
#[ test]
@@ -50,14 +51,14 @@ fn benchmark_expand_macro_rules() {
50
51
assert_eq ! ( hash, 69413 ) ;
51
52
}
52
53
53
- fn macro_rules_fixtures ( ) -> FxHashMap < String , DeclarativeMacro < DummyTestSpanData > > {
54
+ fn macro_rules_fixtures ( ) -> FxHashMap < String , DeclarativeMacro < Span > > {
54
55
macro_rules_fixtures_tt ( )
55
56
. into_iter ( )
56
57
. map ( |( id, tt) | ( id, DeclarativeMacro :: parse_macro_rules ( & tt, true , true ) ) )
57
58
. collect ( )
58
59
}
59
60
60
- fn macro_rules_fixtures_tt ( ) -> FxHashMap < String , tt:: Subtree < DummyTestSpanData > > {
61
+ fn macro_rules_fixtures_tt ( ) -> FxHashMap < String , tt:: Subtree < Span > > {
61
62
let fixture = bench_fixture:: numerous_macro_rules ( ) ;
62
63
let source_file = ast:: SourceFile :: parse ( & fixture) . ok ( ) . unwrap ( ) ;
63
64
@@ -79,8 +80,8 @@ fn macro_rules_fixtures_tt() -> FxHashMap<String, tt::Subtree<DummyTestSpanData>
79
80
80
81
/// Generate random invocation fixtures from rules
81
82
fn invocation_fixtures (
82
- rules : & FxHashMap < String , DeclarativeMacro < DummyTestSpanData > > ,
83
- ) -> Vec < ( String , tt:: Subtree < DummyTestSpanData > ) > {
83
+ rules : & FxHashMap < String , DeclarativeMacro < Span > > ,
84
+ ) -> Vec < ( String , tt:: Subtree < Span > ) > {
84
85
let mut seed = 123456789 ;
85
86
let mut res = Vec :: new ( ) ;
86
87
@@ -128,8 +129,8 @@ fn invocation_fixtures(
128
129
return res;
129
130
130
131
fn collect_from_op (
131
- op : & Op < DummyTestSpanData > ,
132
- token_trees : & mut Vec < tt:: TokenTree < DummyTestSpanData > > ,
132
+ op : & Op < Span > ,
133
+ token_trees : & mut Vec < tt:: TokenTree < Span > > ,
133
134
seed : & mut usize ,
134
135
) {
135
136
return match op {
@@ -221,19 +222,19 @@ fn invocation_fixtures(
221
222
* seed = usize:: wrapping_add ( usize:: wrapping_mul ( * seed, a) , c) ;
222
223
* seed
223
224
}
224
- fn make_ident ( ident : & str ) -> tt:: TokenTree < DummyTestSpanData > {
225
+ fn make_ident ( ident : & str ) -> tt:: TokenTree < Span > {
225
226
tt:: Leaf :: Ident ( tt:: Ident { span : DUMMY , text : SmolStr :: new ( ident) } ) . into ( )
226
227
}
227
- fn make_punct ( char : char ) -> tt:: TokenTree < DummyTestSpanData > {
228
+ fn make_punct ( char : char ) -> tt:: TokenTree < Span > {
228
229
tt:: Leaf :: Punct ( tt:: Punct { span : DUMMY , char, spacing : tt:: Spacing :: Alone } ) . into ( )
229
230
}
230
- fn make_literal ( lit : & str ) -> tt:: TokenTree < DummyTestSpanData > {
231
+ fn make_literal ( lit : & str ) -> tt:: TokenTree < Span > {
231
232
tt:: Leaf :: Literal ( tt:: Literal { span : DUMMY , text : SmolStr :: new ( lit) } ) . into ( )
232
233
}
233
234
fn make_subtree (
234
235
kind : tt:: DelimiterKind ,
235
- token_trees : Option < Vec < tt:: TokenTree < DummyTestSpanData > > > ,
236
- ) -> tt:: TokenTree < DummyTestSpanData > {
236
+ token_trees : Option < Vec < tt:: TokenTree < Span > > > ,
237
+ ) -> tt:: TokenTree < Span > {
237
238
tt:: Subtree {
238
239
delimiter : tt:: Delimiter { open : DUMMY , close : DUMMY , kind } ,
239
240
token_trees : token_trees. map ( Vec :: into_boxed_slice) . unwrap_or_default ( ) ,
0 commit comments