Skip to content

Commit 0e2337a

Browse files
committed
Deny #[deprecated] on trait impl blocks.
They have no effect there, but were silently accepted.
1 parent b202532 commit 0e2337a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_passes/src/stability.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ enum AnnotationKind {
3131
Required,
3232
// Annotation is useless, reject it
3333
Prohibited,
34+
// Deprecation annotation is useless, reject it. (Stability attribute is still required.)
35+
DeprecationProhibited,
3436
// Annotation itself is useless, but it can be propagated to children
3537
Container,
3638
}
@@ -89,7 +91,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
8991
if let Some(depr) = &depr {
9092
is_deprecated = true;
9193

92-
if kind == AnnotationKind::Prohibited {
94+
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
9395
self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless");
9496
}
9597

@@ -322,6 +324,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
322324
}
323325
hir::ItemKind::Impl { of_trait: Some(_), .. } => {
324326
self.in_trait_impl = true;
327+
kind = AnnotationKind::DeprecationProhibited;
325328
}
326329
hir::ItemKind::Struct(ref sd, _) => {
327330
if let Some(ctor_hir_id) = sd.ctor_hir_id() {

0 commit comments

Comments
 (0)