Skip to content

Commit e6fc0c4

Browse files
authored
Rollup merge of rust-lang#97005 - est31:master, r=petrochenkov
Two small improvements of rustc_expand I found them while doing rust-lang#96150 r? ``@petrochenkov``
2 parents 93a4dfd + e6ccf9b commit e6fc0c4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ crate use ParseResult::*;
7676
use crate::mbe::{KleeneOp, TokenTree};
7777

7878
use rustc_ast::token::{self, DocComment, Nonterminal, NonterminalKind, Token};
79+
use rustc_lint_defs::pluralize;
7980
use rustc_parse::parser::{NtOrTt, Parser};
8081
use rustc_span::symbol::MacroRulesNormalizedIdent;
8182
use rustc_span::Span;
@@ -668,8 +669,7 @@ impl TtParser {
668669
self.macro_name,
669670
match self.next_mps.len() {
670671
0 => format!("built-in NTs {}.", nts),
671-
1 => format!("built-in NTs {} or 1 other option.", nts),
672-
n => format!("built-in NTs {} or {} other options.", nts, n),
672+
n => format!("built-in NTs {} or {n} other option{s}.", nts, s = pluralize!(n)),
673673
}
674674
),
675675
)

compiler/rustc_expand/src/mbe/macro_rules.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl TTMacroExpander for MacroRulesMacroExpander {
175175
if !self.valid {
176176
return DummyResult::any(sp);
177177
}
178-
generic_extension(
178+
expand_macro(
179179
cx,
180180
sp,
181181
self.span,
@@ -202,8 +202,9 @@ fn trace_macros_note(cx_expansions: &mut FxHashMap<Span, Vec<String>>, sp: Span,
202202
cx_expansions.entry(sp).or_default().push(message);
203203
}
204204

205-
/// Given `lhses` and `rhses`, this is the new macro we create
206-
fn generic_extension<'cx, 'tt>(
205+
/// Expands the rules based macro defined by `lhses` and `rhses` for a given
206+
/// input `arg`.
207+
fn expand_macro<'cx, 'tt>(
207208
cx: &'cx mut ExtCtxt<'_>,
208209
sp: Span,
209210
def_span: Span,

0 commit comments

Comments
 (0)