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 `//`.
```
This commit is contained in:
Matthias Krüger 2024-05-17 07:20:56 +02:00 committed by GitHub
commit e62688eb96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 46 additions and 5 deletions

View file

@ -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();