1
+ use crate :: errors;
1
2
use crate :: mbe:: macro_parser:: count_metavar_decls;
2
3
use crate :: mbe:: { Delimited , KleeneOp , KleeneToken , MetaVarExpr , SequenceRepetition , TokenTree } ;
3
4
@@ -60,11 +61,11 @@ pub(super) fn parse(
60
61
Some ( & tokenstream:: TokenTree :: Token ( Token { kind : token:: Colon , span } , _) ) => {
61
62
match trees. next ( ) {
62
63
Some ( tokenstream:: TokenTree :: Token ( token, _) ) => match token. ident ( ) {
63
- Some ( ( frag , _) ) => {
64
+ Some ( ( fragment , _) ) => {
64
65
let span = token. span . with_lo ( start_sp. lo ( ) ) ;
65
66
66
67
let kind =
67
- token:: NonterminalKind :: from_symbol ( frag . name , || {
68
+ token:: NonterminalKind :: from_symbol ( fragment . name , || {
68
69
// FIXME(#85708) - once we properly decode a foreign
69
70
// crate's `SyntaxContext::root`, then we can replace
70
71
// this with just `span.edition()`. A
@@ -81,14 +82,13 @@ pub(super) fn parse(
81
82
} )
82
83
. unwrap_or_else (
83
84
|| {
84
- let msg = format ! (
85
- "invalid fragment specifier `{}`" ,
86
- frag. name
85
+ sess. dcx ( ) . emit_err (
86
+ errors:: InvalidFragmentSpecifier {
87
+ span,
88
+ fragment,
89
+ help : VALID_FRAGMENT_NAMES_MSG . into ( ) ,
90
+ } ,
87
91
) ;
88
- sess. dcx ( )
89
- . struct_span_err ( span, msg)
90
- . with_help ( VALID_FRAGMENT_NAMES_MSG )
91
- . emit ( ) ;
92
92
token:: NonterminalKind :: Ident
93
93
} ,
94
94
) ;
0 commit comments