@@ -775,6 +775,8 @@ fn check_matcher_core(sess: &ParseSess,
775
775
new. add_one_maybe ( TokenTree :: Token ( delim_sp. entire ( ) , u. clone ( ) ) ) ;
776
776
& new
777
777
} else {
778
+ // Verify that a fragment isn't followed by an invalid fragment type through
779
+ // repetition.
778
780
if let (
779
781
Some ( tok) ,
780
782
Some ( TokenTree :: MetaVarDecl ( sp, name, frag_spec) ) ,
@@ -786,7 +788,7 @@ fn check_matcher_core(sess: &ParseSess,
786
788
let next = if * sp == tok_sp {
787
789
"itself" . to_owned ( )
788
790
} else {
789
- format ! ( "`{}`" , quoted_tt_to_string( tok) )
791
+ quoted_tt_to_string ( tok)
790
792
} ;
791
793
let mut err = sess. span_diagnostic . struct_span_warn (
792
794
* sp,
@@ -817,8 +819,8 @@ fn check_matcher_core(sess: &ParseSess,
817
819
}
818
820
let sugg_span = sess. source_map ( ) . next_point ( delim_sp. close ) ;
819
821
let msg = "allowed there are: " ;
820
- let sugg_msg = "add a valid separator for the repetition to be \
821
- unambiguous";
822
+ let sugg_msg =
823
+ "add a valid separator for the repetition to be unambiguous";
822
824
match & possible[ ..] {
823
825
& [ ] => { }
824
826
& [ t] => {
@@ -914,7 +916,7 @@ fn check_matcher_core(sess: &ParseSess,
914
916
let sp = next_token. span ( ) ;
915
917
let mut err = sess. span_diagnostic . struct_span_err (
916
918
sp,
917
- & format ! ( "`${name}:{frag}` {may_be} followed by ` {next}` , which \
919
+ & format ! ( "`${name}:{frag}` {may_be} followed by {next}, which \
918
920
is not allowed for `{frag}` fragments",
919
921
name=name,
920
922
frag=frag_spec,
@@ -1140,9 +1142,13 @@ fn is_legal_fragment_specifier(sess: &ParseSess,
1140
1142
1141
1143
fn quoted_tt_to_string ( tt : & quoted:: TokenTree ) -> String {
1142
1144
match * tt {
1143
- quoted:: TokenTree :: Token ( _, ref tok) => :: print:: pprust:: token_to_string ( tok) ,
1144
- quoted:: TokenTree :: MetaVar ( _, name) => format ! ( "${}" , name) ,
1145
- quoted:: TokenTree :: MetaVarDecl ( _, name, kind) => format ! ( "${}:{}" , name, kind) ,
1146
- ref tt => panic ! ( "unexpected {:?} in follow set checker" , tt) ,
1145
+ quoted:: TokenTree :: Token ( _, ref tok) => format ! (
1146
+ "`{}`" ,
1147
+ :: print:: pprust:: token_to_string( tok) ,
1148
+ ) ,
1149
+ quoted:: TokenTree :: MetaVar ( _, name) => format ! ( "`${}`" , name) ,
1150
+ quoted:: TokenTree :: MetaVarDecl ( _, name, kind) => format ! ( "`${}:{}`" , name, kind) ,
1151
+ quoted:: TokenTree :: Delimited ( ..) => "a delimited token tree" . to_owned ( ) ,
1152
+ quoted:: TokenTree :: Sequence ( ..) => "a sequence" . to_owned ( ) ,
1147
1153
}
1148
1154
}
0 commit comments