Skip to content

Commit

Permalink
rustc_expand: make diagnostic translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiretza committed Apr 22, 2024
1 parent bfacfe2 commit 3289a9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_expand/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ expand_attribute_meta_item =
expand_attribute_single_word =
attribute must only be a single word
expand_attributes_on_expressions_experimental =
attributes on expressions are experimental
.help_outer_doc = `///` is used for outer documentation comments; for a plain comment, use `//`
.help_inner_doc = `//!` is used for inner documentation comments; for a plain comment, use `//` by removing the `!` or inserting a space in between them: `// !`
expand_attributes_wrong_form =
attribute must be of form: `attributes(foo, bar)`
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ impl<'a> StripUnconfigured<'a> {
}

/// If attributes are not allowed on expressions, emit an error for `attr`
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
#[instrument(level = "trace", skip(self))]
pub(crate) fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
if self.features.is_some_and(|features| !features.stmt_expr_attributes)
Expand All @@ -383,14 +382,14 @@ impl<'a> StripUnconfigured<'a> {
&self.sess,
sym::stmt_expr_attributes,
attr.span,
"attributes on expressions are experimental",
crate::fluent_generated::expand_attributes_on_expressions_experimental,
);

if attr.is_doc_comment() {
err.help(if attr.style == AttrStyle::Outer {
"`///` is used for outer documentation comments; for a plain comment, use `//`"
crate::fluent_generated::expand_help_outer_doc
} else {
"`//!` is used for inner documentation comments; for a plain comment, use `//` by removing the `!` or inserting a space in between them: `// !`"
crate::fluent_generated::expand_help_inner_doc
});
}

Expand Down

0 comments on commit 3289a9a

Please sign in to comment.