Change:
Here's some code incorrectly defining a macro, because it's missing a fragment specifier. Here's the error message rustc gives me: It's potentially confusing that the error points to the source after the name with the missing fragment specifier. Especially in a complicated macro, it would be better if it pointed to the item which was actually missing the fragment specifier. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim
Some more context at

Discussion:
// For each token tree in `input`, parse the token into a `self::TokenTree`, consuming // additional trees if need be. <del> let mut trees = input.trees(); </del> <ins> let mut trees = input.trees().peekable(); </ins> while let Some(tree) = trees.next() { // Given the parsed tree, if there is a metavar and we are expecting matchers, actually // parse out the matcher (i.e., in `$id:ident` this would parse the `:` and `ident`). let tree = parse_tree(tree, &mut trees, parsing_patterns, sess, node_id, features, edition); match tree { TokenTree::MetaVar(start_sp, ident) if parsing_patterns => { <del> let span = match trees.next() { </del> <ins> // Not consuming the next token immediately, as it may not be a colon let span = match trees.peek() { </ins> Some(&tokenstream::TokenTree::Token( Token { kind: token::Colon, span: colon_span }, _, )) => { <ins> // Consume the colon first trees.next(); // It's ok to consume the next tree no matter how, // since if it's not a token then it will be an invalid declaration. </ins> match trees.next() { Some(tokenstream::TokenTree::Token(token, _)) => match token.ident() { Some((fragment, _)) => {

} _ => token.span, }, <del> Some(tree) => tree.span(), None => colon_span, </del> <ins> // Invalid, return a nice source location _ => colon_span.with_lo(start_sp.lo()), </ins> } } <del> Some(tree) => tree.span(), None => start_sp, </del> <ins> // Whether it's none or some other tree, it doesn't belong to // the current meta variable, returning the original span. _ => start_sp, </ins> }; result.push(TokenTree::MetaVarDecl(span, ident, None));

error: missing fragment specifier <del> --> $DIR/macro-match-nonterminal.rs:2:8 </del> <ins> --> $DIR/macro-match-nonterminal.rs:2:6 </ins> | LL |     ($a, $b) => { <del> |        ^ </del> <ins> |      ^^ </ins> error: missing fragment specifier <del> --> $DIR/macro-match-nonterminal.rs:2:8 </del> <ins> --> $DIR/macro-match-nonterminal.rs:2:6 </ins> | LL |     ($a, $b) => { <del> |        ^ </del> <ins> |      ^^ </ins> | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>

Future incompatibility report: Future breakage diagnostic: error: missing fragment specifier <del> --> $DIR/macro-match-nonterminal.rs:2:8 </del> <ins> --> $DIR/macro-match-nonterminal.rs:2:6 </ins> | LL |     ($a, $b) => { <del> |        ^ </del> <ins> |      ^^ </ins> | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>