@@ -803,6 +803,8 @@ fn check_matcher_core(sess: &ParseSess,
803803 new. add_one_maybe ( TokenTree :: Token ( delim_sp. entire ( ) , u. clone ( ) ) ) ;
804804 & new
805805 } else {
806+ // Verify that a fragment isn't followed by an invalid fragment type through
807+ // repetition.
806808 if let (
807809 Some ( tok) ,
808810 Some ( TokenTree :: MetaVarDecl ( sp, name, frag_spec) ) ,
@@ -814,7 +816,7 @@ fn check_matcher_core(sess: &ParseSess,
814816 let next = if * sp == tok_sp {
815817 "itself" . to_owned ( )
816818 } else {
817- format ! ( "`{}`" , quoted_tt_to_string( tok) )
819+ quoted_tt_to_string ( tok)
818820 } ;
819821 let mut err = sess. span_diagnostic . struct_span_warn (
820822 * sp,
@@ -845,8 +847,8 @@ fn check_matcher_core(sess: &ParseSess,
845847 }
846848 let sugg_span = sess. source_map ( ) . next_point ( delim_sp. close ) ;
847849 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";
850852 match & possible[ ..] {
851853 & [ ] => { }
852854 & [ t] => {
@@ -942,7 +944,7 @@ fn check_matcher_core(sess: &ParseSess,
942944 let sp = next_token. span ( ) ;
943945 let mut err = sess. span_diagnostic . struct_span_err (
944946 sp,
945- & format ! ( "`${name}:{frag}` {may_be} followed by ` {next}` , which \
947+ & format ! ( "`${name}:{frag}` {may_be} followed by {next}, which \
946948 is not allowed for `{frag}` fragments",
947949 name=name,
948950 frag=frag_spec,
@@ -1163,9 +1165,13 @@ fn is_legal_fragment_specifier(_sess: &ParseSess,
11631165
11641166fn quoted_tt_to_string ( tt : & quoted:: TokenTree ) -> String {
11651167 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 ( ) ,
11701176 }
11711177}
0 commit comments