@@ -803,6 +803,8 @@ fn check_matcher_core(sess: &ParseSess,
803
803
new. add_one_maybe ( TokenTree :: Token ( delim_sp. entire ( ) , u. clone ( ) ) ) ;
804
804
& new
805
805
} else {
806
+ // Verify that a fragment isn't followed by an invalid fragment type through
807
+ // repetition.
806
808
if let (
807
809
Some ( tok) ,
808
810
Some ( TokenTree :: MetaVarDecl ( sp, name, frag_spec) ) ,
@@ -814,7 +816,7 @@ fn check_matcher_core(sess: &ParseSess,
814
816
let next = if * sp == tok_sp {
815
817
"itself" . to_owned ( )
816
818
} else {
817
- format ! ( "`{}`" , quoted_tt_to_string( tok) )
819
+ quoted_tt_to_string ( tok)
818
820
} ;
819
821
let mut err = sess. span_diagnostic . struct_span_warn (
820
822
* sp,
@@ -845,8 +847,8 @@ fn check_matcher_core(sess: &ParseSess,
845
847
}
846
848
let sugg_span = sess. source_map ( ) . next_point ( delim_sp. close ) ;
847
849
let msg = "allowed there are: " ;
848
- let sugg_msg = "add a valid separator for the repetition to be \
849
- unambiguous";
850
+ let sugg_msg =
851
+ "add a valid separator for the repetition to be unambiguous";
850
852
match & possible[ ..] {
851
853
& [ ] => { }
852
854
& [ t] => {
@@ -942,7 +944,7 @@ fn check_matcher_core(sess: &ParseSess,
942
944
let sp = next_token. span ( ) ;
943
945
let mut err = sess. span_diagnostic . struct_span_err (
944
946
sp,
945
- & format ! ( "`${name}:{frag}` {may_be} followed by ` {next}` , which \
947
+ & format ! ( "`${name}:{frag}` {may_be} followed by {next}, which \
946
948
is not allowed for `{frag}` fragments",
947
949
name=name,
948
950
frag=frag_spec,
@@ -1163,9 +1165,13 @@ fn is_legal_fragment_specifier(_sess: &ParseSess,
1163
1165
1164
1166
fn quoted_tt_to_string ( tt : & quoted:: TokenTree ) -> String {
1165
1167
match * tt {
1166
- quoted:: TokenTree :: Token ( _, ref tok) => :: print:: pprust:: token_to_string ( tok) ,
1167
- quoted:: TokenTree :: MetaVar ( _, name) => format ! ( "${}" , name) ,
1168
- quoted:: TokenTree :: MetaVarDecl ( _, name, kind) => format ! ( "${}:{}" , name, kind) ,
1169
- ref tt => panic ! ( "unexpected {:?} in follow set checker" , tt) ,
1168
+ quoted:: TokenTree :: Token ( _, ref tok) => format ! (
1169
+ "`{}`" ,
1170
+ :: print:: pprust:: token_to_string( tok) ,
1171
+ ) ,
1172
+ quoted:: TokenTree :: MetaVar ( _, name) => format ! ( "`${}`" , name) ,
1173
+ quoted:: TokenTree :: MetaVarDecl ( _, name, kind) => format ! ( "`${}:{}`" , name, kind) ,
1174
+ quoted:: TokenTree :: Delimited ( ..) => "a delimited token tree" . to_owned ( ) ,
1175
+ quoted:: TokenTree :: Sequence ( ..) => "a sequence" . to_owned ( ) ,
1170
1176
}
1171
1177
}
0 commit comments