diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-05-17 07:20:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-17 07:20:56 +0200 |
| commit | e62688eb966952ae7ec4d049150bb84e657eb4ca (patch) | |
| tree | 910f6431992124da71c6dec0b10c3701b8f783db /compiler | |
| parent | 8af67ba01a1b1d95ff375b645ef5a395d3249e09 (diff) | |
| parent | 3289a9a60dfbccce41e4db989708f5807a24cbdb (diff) | |
| download | rust-e62688eb966952ae7ec4d049150bb84e657eb4ca.tar.gz rust-e62688eb966952ae7ec4d049150bb84e657eb4ca.zip | |
Rollup merge of #123694 - Xiretza:expand-diagnostics, r=compiler-errors
expand: fix minor diagnostics bug The error mentions `///`, when it's actually `//!`: ``` error[E0658]: attributes on expressions are experimental --> test.rs:4:9 | 4 | //! wah | ^^^^^^^ | = note: see issue https://github.com/rust-lang/rust/issues/15701 <https://github.com/rust-lang/rust/issues/15701> for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = help: `///` is for documentation comments. For a plain comment, use `//`. ```
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_expand/messages.ftl | 5 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/config.rs | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler/rustc_expand/messages.ftl b/compiler/rustc_expand/messages.ftl index 7ae988a5be6..530b37aadb1 100644 --- a/compiler/rustc_expand/messages.ftl +++ b/compiler/rustc_expand/messages.ftl @@ -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)` diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index 67a5a9128cc..35f0d8abffc 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -382,7 +382,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) @@ -392,11 +391,15 @@ 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("`///` is for documentation comments. For a plain comment, use `//`."); + err.help(if attr.style == AttrStyle::Outer { + crate::fluent_generated::expand_help_outer_doc + } else { + crate::fluent_generated::expand_help_inner_doc + }); } err.emit(); |
