@@ -17,7 +17,7 @@ use crate::symbol::{Symbol, kw, sym};
1717use crate :: tokenstream:: { DelimSpan , TokenStream , TokenTree } ;
1818
1919use errors:: FatalError ;
20- use syntax_pos:: { Span , DUMMY_SP , symbol:: Ident } ;
20+ use syntax_pos:: { Span , symbol:: Ident } ;
2121use log:: debug;
2222
2323use rustc_data_structures:: fx:: { FxHashMap } ;
@@ -266,17 +266,19 @@ pub fn compile(
266266 let argument_gram = vec ! [
267267 quoted:: TokenTree :: Sequence ( DelimSpan :: dummy( ) , Lrc :: new( quoted:: SequenceRepetition {
268268 tts: vec![
269- quoted:: TokenTree :: MetaVarDecl ( DUMMY_SP , lhs_nm, ast:: Ident :: from_str( "tt" ) ) ,
270- quoted:: TokenTree :: token( token:: FatArrow , DUMMY_SP ) ,
271- quoted:: TokenTree :: MetaVarDecl ( DUMMY_SP , rhs_nm, ast:: Ident :: from_str( "tt" ) ) ,
269+ quoted:: TokenTree :: MetaVarDecl ( def . span , lhs_nm, ast:: Ident :: from_str( "tt" ) ) ,
270+ quoted:: TokenTree :: token( token:: FatArrow , def . span ) ,
271+ quoted:: TokenTree :: MetaVarDecl ( def . span , rhs_nm, ast:: Ident :: from_str( "tt" ) ) ,
272272 ] ,
273- separator: Some ( if body. legacy { token:: Semi } else { token:: Comma } ) ,
273+ separator: Some ( Token :: new(
274+ if body. legacy { token:: Semi } else { token:: Comma } , def. span
275+ ) ) ,
274276 op: quoted:: KleeneOp :: OneOrMore ,
275277 num_captures: 2 ,
276278 } ) ) ,
277279 // to phase into semicolon-termination instead of semicolon-separation
278280 quoted:: TokenTree :: Sequence ( DelimSpan :: dummy( ) , Lrc :: new( quoted:: SequenceRepetition {
279- tts: vec![ quoted:: TokenTree :: token( token:: Semi , DUMMY_SP ) ] ,
281+ tts: vec![ quoted:: TokenTree :: token( token:: Semi , def . span ) ] ,
280282 separator: None ,
281283 op: quoted:: KleeneOp :: ZeroOrMore ,
282284 num_captures: 0
@@ -608,9 +610,8 @@ impl FirstSets {
608610 // If the sequence contents can be empty, then the first
609611 // token could be the separator token itself.
610612
611- if let ( Some ( ref sep) , true ) = ( seq_rep. separator . clone ( ) ,
612- subfirst. maybe_empty ) {
613- first. add_one_maybe ( TokenTree :: token ( sep. clone ( ) , sp. entire ( ) ) ) ;
613+ if let ( Some ( sep) , true ) = ( & seq_rep. separator , subfirst. maybe_empty ) {
614+ first. add_one_maybe ( TokenTree :: Token ( sep. clone ( ) ) ) ;
614615 }
615616
616617 // Reverse scan: Sequence comes before `first`.
@@ -658,9 +659,8 @@ impl FirstSets {
658659 // If the sequence contents can be empty, then the first
659660 // token could be the separator token itself.
660661
661- if let ( Some ( ref sep) , true ) = ( seq_rep. separator . clone ( ) ,
662- subfirst. maybe_empty ) {
663- first. add_one_maybe ( TokenTree :: token ( sep. clone ( ) , sp. entire ( ) ) ) ;
662+ if let ( Some ( sep) , true ) = ( & seq_rep. separator , subfirst. maybe_empty ) {
663+ first. add_one_maybe ( TokenTree :: Token ( sep. clone ( ) ) ) ;
664664 }
665665
666666 assert ! ( first. maybe_empty) ;
@@ -851,7 +851,7 @@ fn check_matcher_core(sess: &ParseSess,
851851 // against SUFFIX
852852 continue ' each_token;
853853 }
854- TokenTree :: Sequence ( sp , ref seq_rep) => {
854+ TokenTree :: Sequence ( _ , ref seq_rep) => {
855855 suffix_first = build_suffix_first ( ) ;
856856 // The trick here: when we check the interior, we want
857857 // to include the separator (if any) as a potential
@@ -864,9 +864,9 @@ fn check_matcher_core(sess: &ParseSess,
864864 // work of cloning it? But then again, this way I may
865865 // get a "tighter" span?
866866 let mut new;
867- let my_suffix = if let Some ( ref u ) = seq_rep. separator {
867+ let my_suffix = if let Some ( sep ) = & seq_rep. separator {
868868 new = suffix_first. clone ( ) ;
869- new. add_one_maybe ( TokenTree :: token ( u . clone ( ) , sp . entire ( ) ) ) ;
869+ new. add_one_maybe ( TokenTree :: Token ( sep . clone ( ) ) ) ;
870870 & new
871871 } else {
872872 & suffix_first
0 commit comments