Skip to content

Commit 3465b25

Browse files
committed
Update do_not_recommend docs
A few updates for the docs here: - Fix mistake using wrong attribute name - Add annotations - Try to clarify what kind of behavior the attribute has - Separate allowed-positions, and syntax as separate concerns.
1 parent 8c9da69 commit 3465b25

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/attributes/diagnostics.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ The `deprecated` attribute has several forms:
329329
r[attributes.diagnostic.deprecated.allowed-positions]
330330
The `deprecated` attribute may be applied to any [item], [trait item], [enum
331331
variant], [struct field], [external block item], or [macro definition]. It
332-
cannot be applied to [trait implementation items]. When applied to an item
332+
cannot be applied to [trait implementation items][trait-impl]. When applied to an item
333333
containing other items, such as a [module] or [implementation], all child
334334
items inherit the deprecation attribute.
335335
<!-- NOTE: It is only rejected for trait impl items
@@ -561,8 +561,16 @@ error[E0277]: My Message for `ImportantTrait<i32>` implemented for `String`
561561

562562
### The `diagnostic::do_not_recommend` attribute
563563

564-
The `#[diagnostic::on_unimplemented]` attribute is a hint to the compiler to not show a certain trait implementation as part of the error message.
565-
The attribute should be placed on a [trait implementation items]. It does not accept any arguments. If the attribute is placed in a wrong location or contains an unexpected argument the compiler might emit a warning and otherwise ignore the malformed part.
564+
r[attributes.diagnostic.do_not_recommend]
565+
566+
r[attributes.diagnostic.do_not_recommend.intro]
567+
The `#[diagnostic::do_not_recommend]` attribute is a hint to the compiler to not show the annotated trait implementation as part of a diagnostic message. For example, in an error message about a type not implementing a required trait, the compiler may indicate that an unsatisfied trait bound is a result of the given trait implementation. The `#[diagnostic::do_not_recommend]` attribute can be used to prevent those annotations about the trait implementation from being included in the diagnostic when they are unlikely to be useful.
568+
569+
r[attributes.diagnostic.do_not_recommend.allowed-positions]
570+
The attribute should be placed on a [trait implementation item][trait-impl], though it is not an error to be located in other positions.
571+
572+
r[attributes.diagnostic.do_not_recommend.syntax]
573+
The attribute does not accept any arguments, though unexpected arguments are not considered as an error.
566574

567575
In this example:
568576

@@ -598,7 +606,7 @@ LL | fn needs_foo<T: Foo>() {}
598606
error: aborting due to 1 previous error
599607
```
600608

601-
Without the attribute the compiler would complain about `*mut (): Send` instead.
609+
Without the attribute the compiler would complain about `Send` not being implemented for `*mut ()` due to the required bounds in the implementation.
602610

603611
[Clippy]: https://github.com/rust-lang/rust-clippy
604612
[_MetaListNameValueStr_]: ../attributes.md#meta-item-attribute-syntax
@@ -628,7 +636,7 @@ Without the attribute the compiler would complain about `*mut (): Send` instead.
628636
[struct field]: ../items/structs.md
629637
[struct]: ../items/structs.md
630638
[trait declaration]: ../items/traits.md
631-
[trait implementation items]: ../items/implementations.md#trait-implementations
632639
[trait item]: ../items/traits.md
640+
[trait-impl]: ../items/implementations.md#trait-implementations
633641
[traits]: ../items/traits.md
634642
[union]: ../items/unions.md

0 commit comments

Comments
 (0)