diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-10-31 15:34:10 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2020-11-01 20:48:58 +0100 |
| commit | 0e2337a5d683c04004226502d2243ceb89cf4c22 (patch) | |
| tree | 5f5f2808e499b2c942e6fea399da290f400f5f1f /compiler/rustc_passes/src | |
| parent | b2025326088b54fb3f083bebeba14e0a15bf00d3 (diff) | |
| download | rust-0e2337a5d683c04004226502d2243ceb89cf4c22.tar.gz rust-0e2337a5d683c04004226502d2243ceb89cf4c22.zip | |
Deny #[deprecated] on trait impl blocks.
They have no effect there, but were silently accepted.
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/stability.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index c9497f2a5b2..18d9e9f78d6 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -31,6 +31,8 @@ enum AnnotationKind { Required, // Annotation is useless, reject it Prohibited, + // Deprecation annotation is useless, reject it. (Stability attribute is still required.) + DeprecationProhibited, // Annotation itself is useless, but it can be propagated to children Container, } @@ -89,7 +91,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { if let Some(depr) = &depr { is_deprecated = true; - if kind == AnnotationKind::Prohibited { + if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited { self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless"); } @@ -322,6 +324,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { } hir::ItemKind::Impl { of_trait: Some(_), .. } => { self.in_trait_impl = true; + kind = AnnotationKind::DeprecationProhibited; } hir::ItemKind::Struct(ref sd, _) => { if let Some(ctor_hir_id) = sd.ctor_hir_id() { |
