From cd5de49eaa522ee10c0e8a6b36a067791270dca2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 24 Jun 2025 04:33:58 -0400 Subject: [PATCH] mbe: Use `TokenTree` as the fallback for invalid fragment specifiers `tt` should match more, so use this for both missing and invalid fragment specifiers. Also remove one unneeded instance of `String`. --- compiler/rustc_expand/src/errors.rs | 2 +- compiler/rustc_expand/src/mbe/quoted.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_expand/src/errors.rs b/compiler/rustc_expand/src/errors.rs index ec0af67c0463..b697f2049bd8 100644 --- a/compiler/rustc_expand/src/errors.rs +++ b/compiler/rustc_expand/src/errors.rs @@ -444,7 +444,7 @@ pub(crate) struct InvalidFragmentSpecifier { #[primary_span] pub span: Span, pub fragment: Ident, - pub help: String, + pub help: &'static str, } #[derive(Diagnostic)] diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 871b3e5e4de8..2daa4e715584 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -117,9 +117,9 @@ pub(super) fn parse( sess.dcx().emit_err(errors::InvalidFragmentSpecifier { span, fragment, - help: VALID_FRAGMENT_NAMES_MSG.into(), + help: VALID_FRAGMENT_NAMES_MSG, }); - NonterminalKind::Ident + NonterminalKind::TT }); result.push(TokenTree::MetaVarDecl { span, name: ident, kind }); } else {