@@ -6,20 +6,20 @@ mod matcher;
6
6
mod transcriber;
7
7
8
8
use rustc_hash:: FxHashMap ;
9
+ use span:: Span ;
9
10
use syntax:: SmolStr ;
10
- use tt:: Span ;
11
11
12
12
use crate :: { parser:: MetaVarKind , ExpandError , ExpandResult } ;
13
13
14
- pub ( crate ) fn expand_rules < S : Span > (
15
- rules : & [ crate :: Rule < S > ] ,
16
- input : & tt:: Subtree < S > ,
17
- marker : impl Fn ( & mut S ) + Copy ,
14
+ pub ( crate ) fn expand_rules (
15
+ rules : & [ crate :: Rule ] ,
16
+ input : & tt:: Subtree < Span > ,
17
+ marker : impl Fn ( & mut Span ) + Copy ,
18
18
is_2021 : bool ,
19
19
new_meta_vars : bool ,
20
- call_site : S ,
21
- ) -> ExpandResult < tt:: Subtree < S > > {
22
- let mut match_: Option < ( matcher:: Match < S > , & crate :: Rule < S > ) > = None ;
20
+ call_site : Span ,
21
+ ) -> ExpandResult < tt:: Subtree < Span > > {
22
+ let mut match_: Option < ( matcher:: Match , & crate :: Rule ) > = None ;
23
23
for rule in rules {
24
24
let new_match = matcher:: match_ ( & rule. lhs , input, is_2021) ;
25
25
@@ -110,38 +110,32 @@ pub(crate) fn expand_rules<S: Span>(
110
110
/// In other words, `Bindings` is a *multi* mapping from `SmolStr` to
111
111
/// `tt::TokenTree`, where the index to select a particular `TokenTree` among
112
112
/// many is not a plain `usize`, but a `&[usize]`.
113
- #[ derive( Debug , Clone , PartialEq , Eq ) ]
114
- struct Bindings < S > {
115
- inner : FxHashMap < SmolStr , Binding < S > > ,
116
- }
117
-
118
- impl < S > Default for Bindings < S > {
119
- fn default ( ) -> Self {
120
- Self { inner : Default :: default ( ) }
121
- }
113
+ #[ derive( Debug , Default , Clone , PartialEq , Eq ) ]
114
+ struct Bindings {
115
+ inner : FxHashMap < SmolStr , Binding > ,
122
116
}
123
117
124
118
#[ derive( Debug , Clone , PartialEq , Eq ) ]
125
- enum Binding < S > {
126
- Fragment ( Fragment < S > ) ,
127
- Nested ( Vec < Binding < S > > ) ,
119
+ enum Binding {
120
+ Fragment ( Fragment ) ,
121
+ Nested ( Vec < Binding > ) ,
128
122
Empty ,
129
123
Missing ( MetaVarKind ) ,
130
124
}
131
125
132
126
#[ derive( Debug , Clone , PartialEq , Eq ) ]
133
- enum Fragment < S > {
127
+ enum Fragment {
134
128
Empty ,
135
129
/// token fragments are just copy-pasted into the output
136
- Tokens ( tt:: TokenTree < S > ) ,
130
+ Tokens ( tt:: TokenTree < Span > ) ,
137
131
/// Expr ast fragments are surrounded with `()` on insertion to preserve
138
132
/// precedence. Note that this impl is different from the one currently in
139
133
/// `rustc` -- `rustc` doesn't translate fragments into token trees at all.
140
134
///
141
135
/// At one point in time, we tried to use "fake" delimiters here à la
142
136
/// proc-macro delimiter=none. As we later discovered, "none" delimiters are
143
137
/// tricky to handle in the parser, and rustc doesn't handle those either.
144
- Expr ( tt:: Subtree < S > ) ,
138
+ Expr ( tt:: Subtree < Span > ) ,
145
139
/// There are roughly two types of paths: paths in expression context, where a
146
140
/// separator `::` between an identifier and its following generic argument list
147
141
/// is mandatory, and paths in type context, where `::` can be omitted.
@@ -151,5 +145,5 @@ enum Fragment<S> {
151
145
/// and is trasncribed as an expression-context path, verbatim transcription
152
146
/// would cause a syntax error. We need to fix it up just before transcribing;
153
147
/// see `transcriber::fix_up_and_push_path_tt()`.
154
- Path ( tt:: Subtree < S > ) ,
148
+ Path ( tt:: Subtree < Span > ) ,
155
149
}
0 commit comments