Skip to content

Commit da8f1bd

Browse files
committed
rustc_expand: make mbe translatable
1 parent 8ef38b5 commit da8f1bd

21 files changed

+831
-410
lines changed

Diff for: compiler/rustc_expand/messages.ftl

+112-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@ expand_cannot_be_name_of_macro =
2424
expand_collapse_debuginfo_illegal =
2525
illegal value for attribute #[collapse_debuginfo(no|external|yes)]
2626

27+
expand_concat_generated_invalid_ident = `{"${concat(..)}"}` is not generating a valid identifier
28+
29+
expand_concat_raw_ident = `{"${concat(..)}"}` currently does not support raw identifiers
30+
31+
expand_concat_too_few_args = `concat` must have at least two elements
32+
2733
expand_count_repetition_misplaced =
2834
`count` can not be placed inside the inner-most repetition
2935

36+
expand_count_with_comma_no_index = `count` followed by a comma must have an associated index indicating its depth
37+
3038
expand_custom_attribute_cannot_be_applied =
3139
custom attributes cannot be applied to {$kind ->
3240
[statement] statements
@@ -37,22 +45,37 @@ expand_custom_attribute_panicked =
3745
custom attribute panicked
3846
.help = message: {$message}
3947

48+
expand_doc_comments_ignored_in_matcher_position = doc comments are ignored in matcher position
49+
50+
expand_dollar_or_metavar_in_lhs = unexpected token: {$token}
51+
.note = `$$` and meta-variable expressions are not allowed inside macro parameter definitions
52+
53+
expand_duplicate_binding_name = duplicated bind name: {$bind}
54+
4055
expand_duplicate_matcher_binding = duplicate matcher binding
4156
.label = duplicate binding
4257
.label2 = previous binding
4358

4459
expand_empty_delegation_mac =
4560
empty {$kind} delegation is not supported
4661

62+
expand_expected_comma = expected comma
63+
64+
expand_expected_identifier = expected identifier, found `{$found}`
65+
4766
expand_expected_paren_or_brace =
4867
expected `(` or `{"{"}`, found `{$token}`
4968

69+
expand_expected_repetition_operator = expected one of: `*`, `+`, or `?`
70+
5071
expand_explain_doc_comment_inner =
5172
inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match
5273

5374
expand_explain_doc_comment_outer =
5475
outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match
5576

77+
expand_expr_2021_unstable = fragment specifier `expr_2021` is unstable
78+
5679
expand_expr_repeat_no_syntax_vars =
5780
attempted to repeat an expression containing no syntax variables matched as repeating at this depth
5881

@@ -86,9 +109,30 @@ expand_invalid_cfg_no_parens = `cfg` is not followed by parentheses
86109
expand_invalid_cfg_no_predicate = `cfg` predicate is not specified
87110
expand_invalid_cfg_predicate_literal = `cfg` predicate key cannot be a literal
88111

112+
expand_invalid_concat_arg_type = metavariables of {"`${concat(..)}`"} must be of type `ident`, `literal` or `tt`
113+
.note = currently only string literals are supported
114+
115+
expand_invalid_follow = `${$name}:{$kind}` {$only_option ->
116+
[true] is
117+
*[false] may be
118+
} followed by `{$next}`, which is not allowed for `{$kind}` fragments
119+
.label = not allowed after `{$kind}` fragments
120+
.suggestion = try a `pat_param` fragment specifier instead
121+
.note = {$num_possible ->
122+
[one] only {$possible} is allowed after `{$kind}` fragments
123+
*[other] allowed there are: {$possible}
124+
}
125+
89126
expand_invalid_fragment_specifier =
90127
invalid fragment specifier `{$fragment}`
91-
.help = {$help}
128+
.help_expr_2021 = fragment specifier `expr_2021` requires Rust 2021 or later
129+
130+
expand_label_conflicting_repetition = conflicting repetition
131+
132+
expand_label_error_while_parsing_argument = while parsing argument for this `{$kind}` macro fragment
133+
134+
expand_label_expected_repetition = expected repetition
135+
expand_label_previous_declaration = previous declaration
92136

93137
expand_macro_body_stability =
94138
macros cannot have body stability attributes
@@ -102,19 +146,51 @@ expand_macro_const_stability =
102146

103147
expand_macro_expands_to_match_arm = macros cannot expand to match arms
104148

149+
expand_macro_rhs_must_be_delimited = macro rhs must be delimited
150+
105151
expand_malformed_feature_attribute =
106152
malformed `feature` attribute input
107153
.expected = expected just one word
108154

109-
expand_meta_var_dif_seq_matchers = {$msg}
155+
expand_match_failure_missing_tokens = missing tokens in macro arguments
156+
expand_match_failure_unexpected_token = no rules expected this token in macro call
157+
158+
expand_meta_var_dif_seq_matchers =
159+
meta-variable `{$var1_id}` repeats {$var1_len} {$var1_len ->
160+
[one] time
161+
*[count] times
162+
}, but `{$var2_id}` repeats {$var2_len} {$var2_len ->
163+
[one] time
164+
*[count] times
165+
}
166+
167+
expand_meta_var_expr_concat_unstable = the `concat` meta-variable expression is unstable
168+
169+
expand_meta_var_expr_depth_not_literal = meta-variable expression depth must be a literal
170+
171+
expand_meta_var_expr_depth_suffixed = only unsuffixed integer literals are supported in meta-variable expressions
172+
173+
expand_meta_var_expr_expected_identifier = expected identifier, found `{$found}`
174+
.suggestion = try removing `{$found}`
175+
176+
expand_meta_var_expr_needs_parens = meta-variable expression parameter must be wrapped in parentheses
177+
178+
expand_meta_var_expr_out_of_bounds = {$max ->
179+
[0] meta-variable expression `{$ty}` with depth parameter must be called inside of a macro repetition
180+
*[other] depth parameter of meta-variable expression `{$ty}` must be less than {$max}
181+
}
182+
183+
expand_meta_var_expr_unexpected_token = unexpected token: {$tt}
184+
.note = meta-variable expression must not have trailing tokens
110185

111186
expand_meta_var_expr_unrecognized_var =
112187
variable `{$key}` is not recognized in meta-variable expression
113188

189+
expand_meta_var_expr_unstable = meta-variable expressions are unstable
190+
114191
expand_missing_fragment_specifier = missing fragment specifier
115192
.note = fragment specifiers must be specified in the 2024 edition
116193
.suggestion_add_fragspec = try adding a specifier here
117-
.valid = {$valid}
118194

119195
expand_module_circular =
120196
circular modules: {$modules}
@@ -132,9 +208,22 @@ expand_module_multiple_candidates =
132208
file for module `{$name}` found at both "{$default_path}" and "{$secondary_path}"
133209
.help = delete or rename one of them to remove the ambiguity
134210

211+
expand_multiple_parsing_options =
212+
local ambiguity when calling macro `{$macro_name}`: multiple parsing options: built-in NTs {$nts}{$n ->
213+
[0] .
214+
[one] {""} or {$n} other option
215+
*[other] {""} or {$n} other options
216+
}
217+
218+
expand_multiple_successful_parses = ambiguity: multiple successful parses
219+
220+
expand_multiple_transparency_attrs = multiple macro transparency attributes
221+
135222
expand_must_repeat_once =
136223
this must repeat at least once
137224

225+
expand_nested_meta_var_expr_without_dollar = meta-variables within meta-variable expressions must be referenced using a dollar sign
226+
138227
expand_non_inline_modules_in_proc_macro_input_are_unstable =
139228
non-inline modules in proc macro input are unstable
140229

@@ -144,6 +233,10 @@ expand_not_a_meta_item =
144233
expand_only_one_word =
145234
must only be one word
146235

236+
expand_parse_failure_expected_token = expected `{$expected}`, found `{$found}`
237+
expand_parse_failure_unexpected_eof = unexpected end of macro invocation
238+
expand_parse_failure_unexpected_token = no rules expected the token `{$found}`
239+
147240
expand_proc_macro_back_compat = using an old version of `{$crate_name}`
148241
.note = older versions of the `{$crate_name}` crate no longer compile; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives
149242

@@ -158,6 +251,8 @@ expand_proc_macro_panicked =
158251
proc macro panicked
159252
.help = message: {$message}
160253

254+
expand_question_mark_with_separator = the `?` macro repetition operator does not take a separator
255+
161256
expand_recursion_limit_reached =
162257
recursion limit reached while expanding `{$descr}`
163258
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`)
@@ -168,14 +263,28 @@ expand_remove_expr_not_supported =
168263
expand_remove_node_not_supported =
169264
removing {$descr} is not supported in this position
170265

266+
expand_repetition_matches_empty_token_tree = repetition matches empty token tree
267+
171268
expand_resolve_relative_path =
172269
cannot resolve relative path in non-file source `{$path}`
173270

174271
expand_trace_macro = trace_macro
175272

273+
expand_unbalanced_delims_around_matcher = invalid macro matcher; matchers must be contained in balanced delimiters
274+
275+
expand_unknown_macro_transparency = unknown macro transparency: `{$value}`
276+
277+
expand_unrecognized_meta_var_expr = unrecognized meta-variable expression
278+
.help = supported expressions are count, ignore, index and len
279+
280+
expand_unsupported_concat_elem = expected identifier or string literal
281+
176282
expand_unsupported_key_value =
177283
key-value macro attributes are not supported
178284

285+
expand_valid_fragment_names_2021 = valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
286+
expand_valid_fragment_names_other = valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
287+
179288
expand_var_still_repeating =
180289
variable `{$ident}` is still repeating at this depth
181290

0 commit comments

Comments
 (0)