@@ -323,13 +323,34 @@ The `deprecated` attribute has several forms:
323
323
- `note ` --- Specifies a string that should be included in the deprecation message . This is typically used to provide an explanation about the deprecation and preferred alternatives .
324
324
325
325
r [attributes . diagnostic. deprecated. allowed- positions ]
326
- The `deprecated ` attribute may be applied to any [item ], [trait item ], [enum variant ], [struct field ], [external block item ], or [macro definition ]. It cannot be applied to [trait implementation items ][trait - impl ]. When applied to an item containing other items , such as a [ module ] or [ implementation ], all child items inherit the deprecation attribute .
326
+ The `deprecated ` attribute may be applied to any [item ], [trait item ], [enum variant ], [struct field ], [external block item ], or [macro definition ]. It cannot be applied to [trait implementation items ][trait - impl ].
327
327
328
328
<! -- NOTE : It is only rejected for trait impl items
329
329
(AnnotationKind :: Prohibited ). In all other locations , it is silently ignored .
330
330
Tuple struct fields are ignored .
331
331
- ->
332
332
333
+ r [attributes . diagnostics. deprecated. containers]
334
+ When `deprecated ` is applied to an item containing other items , all child items inherit the deprecation attribute . This includes :
335
+
336
+ - [crate root ]
337
+ - [modules ]
338
+ - [implementations ]
339
+ - [external blocks ]
340
+
341
+ > [! EXAMPLE ]
342
+ > ```rust
343
+ > #[deprecated = " utility functions are no longer supported and will be removed in the future" ]
344
+ > pub mod utils {
345
+ > pub fn trim () {}
346
+ > pub fn flush () {}
347
+ > }
348
+ >
349
+ > fn main () {
350
+ > utils :: trim (); // WARNING: deprecated
351
+ > }
352
+ > ```
353
+
333
354
r [attributes . diagnostics. must_use]
334
355
## The `must_use ` attribute
335
356
@@ -652,19 +673,21 @@ The first error message includes a somewhat confusing error message about the re
652
673
[ attributes ] : ../attributes.md
653
674
[ block expression ] : ../expressions/block-expr.md
654
675
[ call expression ] : ../expressions/call-expr.md
676
+ [ crate root ] : ../crates-and-source-files.md
655
677
[ dyn trait ] : ../types/trait-object.md
656
678
[ enum variant ] : ../items/enumerations.md
657
679
[ enum ] : ../items/enumerations.md
658
680
[ expression statement ] : ../statements.md#expression-statements
659
681
[ expression ] : ../expressions.md
660
682
[ external block item ] : ../items/external-blocks.md
683
+ [ external blocks ] : ../items/external-blocks.md
661
684
[ functions ] : ../items/functions.md
662
685
[ impl trait ] : ../types/impl-trait.md
663
- [ implementation ] : ../items/implementations.md
686
+ [ implementations ] : ../items/implementations.md
664
687
[ item ] : ../items.md
665
688
[ let statement ] : ../statements.md#let-statements
666
689
[ macro definition ] : ../macros-by-example.md
667
- [ module ] : ../items/modules.md
690
+ [ modules ] : ../items/modules.md
668
691
[ rustc book ] : ../../rustc/lints/index.html
669
692
[ rustc-lint-caps ] : ../../rustc/lints/levels.html#capping-lints
670
693
[ rustc-lint-cli ] : ../../rustc/lints/levels.html#via-compiler-flag
0 commit comments