@@ -647,7 +647,7 @@ fn check_matcher_core(sess: &ParseSess,
647
647
let msg = format ! ( "invalid fragment specifier `{}`" , bad_frag) ;
648
648
sess. span_diagnostic . struct_span_err ( token. span ( ) , & msg)
649
649
. help ( "valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, \
650
- `pat`, `ty`, `path`, `meta`, `tt`, `item` and `vis`")
650
+ `pat`, `ty`, `literal`, ` path`, `meta`, `tt`, `item` and `vis`")
651
651
. emit ( ) ;
652
652
// (This eliminates false positives and duplicates
653
653
// from error messages.)
@@ -784,6 +784,7 @@ fn frag_can_be_followed_by_any(frag: &str) -> bool {
784
784
"item" | // always terminated by `}` or `;`
785
785
"block" | // exactly one token tree
786
786
"ident" | // exactly one token tree
787
+ "literal" | // exactly one token tree
787
788
"meta" | // exactly one token tree
788
789
"lifetime" | // exactly one token tree
789
790
"tt" => // exactly one token tree
@@ -850,6 +851,10 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result<bool, (String, &'
850
851
// being a single token, idents and lifetimes are harmless
851
852
Ok ( true )
852
853
} ,
854
+ "literal" => {
855
+ // literals may be of a single token, or two tokens (negative numbers)
856
+ Ok ( true )
857
+ } ,
853
858
"meta" | "tt" => {
854
859
// being either a single token or a delimited sequence, tt is
855
860
// harmless
@@ -873,7 +878,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result<bool, (String, &'
873
878
_ => Err ( ( format ! ( "invalid fragment specifier `{}`" , frag) ,
874
879
"valid fragment specifiers are `ident`, `block`, \
875
880
`stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt`, \
876
- `item` and `vis`") )
881
+ `literal`, ` item` and `vis`") )
877
882
}
878
883
}
879
884
}
@@ -913,6 +918,18 @@ fn is_legal_fragment_specifier(sess: &ParseSess,
913
918
}
914
919
true
915
920
} ,
921
+ "literal" => {
922
+ if !features. macro_literal_matcher &&
923
+ !attr:: contains_name ( attrs, "allow_internal_unstable" ) {
924
+ let explain = feature_gate:: EXPLAIN_LITERAL_MATCHER ;
925
+ emit_feature_err ( sess,
926
+ "macro_literal_matcher" ,
927
+ frag_span,
928
+ GateIssue :: Language ,
929
+ explain) ;
930
+ }
931
+ true
932
+ } ,
916
933
"vis" => {
917
934
if !features. macro_vis_matcher &&
918
935
!attr:: contains_name ( attrs, "allow_internal_unstable" ) {
0 commit comments