@@ -6,20 +6,20 @@ mod matcher;
66mod transcriber;
77
88use rustc_hash:: FxHashMap ;
9+ use span:: Span ;
910use syntax:: SmolStr ;
10- use tt:: Span ;
1111
1212use crate :: { parser:: MetaVarKind , ExpandError , ExpandResult } ;
1313
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 ,
1818 is_2021 : bool ,
1919 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 ;
2323 for rule in rules {
2424 let new_match = matcher:: match_ ( & rule. lhs , input, is_2021) ;
2525
@@ -110,38 +110,32 @@ pub(crate) fn expand_rules<S: Span>(
110110/// In other words, `Bindings` is a *multi* mapping from `SmolStr` to
111111/// `tt::TokenTree`, where the index to select a particular `TokenTree` among
112112/// 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 > ,
122116}
123117
124118#[ 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 > ) ,
128122 Empty ,
129123 Missing ( MetaVarKind ) ,
130124}
131125
132126#[ derive( Debug , Clone , PartialEq , Eq ) ]
133- enum Fragment < S > {
127+ enum Fragment {
134128 Empty ,
135129 /// token fragments are just copy-pasted into the output
136- Tokens ( tt:: TokenTree < S > ) ,
130+ Tokens ( tt:: TokenTree < Span > ) ,
137131 /// Expr ast fragments are surrounded with `()` on insertion to preserve
138132 /// precedence. Note that this impl is different from the one currently in
139133 /// `rustc` -- `rustc` doesn't translate fragments into token trees at all.
140134 ///
141135 /// At one point in time, we tried to use "fake" delimiters here à la
142136 /// proc-macro delimiter=none. As we later discovered, "none" delimiters are
143137 /// tricky to handle in the parser, and rustc doesn't handle those either.
144- Expr ( tt:: Subtree < S > ) ,
138+ Expr ( tt:: Subtree < Span > ) ,
145139 /// There are roughly two types of paths: paths in expression context, where a
146140 /// separator `::` between an identifier and its following generic argument list
147141 /// is mandatory, and paths in type context, where `::` can be omitted.
@@ -151,5 +145,5 @@ enum Fragment<S> {
151145 /// and is trasncribed as an expression-context path, verbatim transcription
152146 /// would cause a syntax error. We need to fix it up just before transcribing;
153147 /// see `transcriber::fix_up_and_push_path_tt()`.
154- Path ( tt:: Subtree < S > ) ,
148+ Path ( tt:: Subtree < Span > ) ,
155149}
0 commit comments