Skip to content

Commit 4c06a1f

Browse files
committed
mbe: Shorten MetaVarExpr -> Mve in structural diagnostics
More diagnostic structs related to metavariable expressions will be introduced. Introduce the abbreviation "mve" which is reasonably unambiguous (`rg Mve` and `rg '(\b|_|-)mve(\b|_|-)'` return no results outside of a Thumb target feature) and use it for these diagnostic types. A new module is also created.
1 parent 3efd7ec commit 4c06a1f

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

compiler/rustc_expand/messages.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ expand_malformed_feature_attribute =
109109
110110
expand_meta_var_dif_seq_matchers = {$msg}
111111
112-
expand_meta_var_expr_unrecognized_var =
113-
variable `{$key}` is not recognized in meta-variable expression
114-
115112
expand_missing_fragment_specifier = missing fragment specifier
116113
.note = fragment specifiers must be provided
117114
.suggestion_add_fragspec = try adding a specifier here
@@ -136,6 +133,9 @@ expand_module_multiple_candidates =
136133
expand_must_repeat_once =
137134
this must repeat at least once
138135
136+
expand_mve_unrecognized_var =
137+
variable `{$key}` is not recognized in meta-variable expression
138+
139139
expand_non_inline_modules_in_proc_macro_input_are_unstable =
140140
non-inline modules in proc macro input are unstable
141141

compiler/rustc_expand/src/errors.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ pub(crate) struct CountRepetitionMisplaced {
2727
pub span: Span,
2828
}
2929

30-
#[derive(Diagnostic)]
31-
#[diag(expand_meta_var_expr_unrecognized_var)]
32-
pub(crate) struct MetaVarExprUnrecognizedVar {
33-
#[primary_span]
34-
pub span: Span,
35-
pub key: MacroRulesNormalizedIdent,
36-
}
37-
3830
#[derive(Diagnostic)]
3931
#[diag(expand_var_still_repeating)]
4032
pub(crate) struct VarStillRepeating {
@@ -500,3 +492,16 @@ pub(crate) struct ProcMacroBackCompat {
500492
pub crate_name: String,
501493
pub fixed_version: String,
502494
}
495+
496+
pub(crate) use metavar_exprs::*;
497+
mod metavar_exprs {
498+
use super::*;
499+
500+
#[derive(Diagnostic)]
501+
#[diag(expand_mve_unrecognized_var)]
502+
pub(crate) struct MveUnrecognizedVar {
503+
#[primary_span]
504+
pub span: Span,
505+
pub key: MacroRulesNormalizedIdent,
506+
}
507+
}

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_span::{
1717
use smallvec::{SmallVec, smallvec};
1818

1919
use crate::errors::{
20-
CountRepetitionMisplaced, MetaVarExprUnrecognizedVar, MetaVarsDifSeqMatchers, MustRepeatOnce,
20+
CountRepetitionMisplaced, MetaVarsDifSeqMatchers, MustRepeatOnce, MveUnrecognizedVar,
2121
NoSyntaxVarsExprRepeat, VarStillRepeating,
2222
};
2323
use crate::mbe::macro_parser::NamedMatch;
@@ -879,7 +879,7 @@ where
879879
{
880880
let span = ident.span;
881881
let key = MacroRulesNormalizedIdent::new(ident);
882-
interp.get(&key).ok_or_else(|| dcx.create_err(MetaVarExprUnrecognizedVar { span, key }))
882+
interp.get(&key).ok_or_else(|| dcx.create_err(MveUnrecognizedVar { span, key }))
883883
}
884884

885885
/// Used by meta-variable expressions when an user input is out of the actual declared bounds. For

0 commit comments

Comments
 (0)