Skip to content

Commit 836cdf0

Browse files
committed
WIP inherited deprecation fixes #26040
1 parent c85f307 commit 836cdf0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/librustc/middle/stability.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,18 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
6060
if self.index.staged_api[&ast::LOCAL_CRATE] {
6161
debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
6262
match attr::find_stability(self.tcx.sess.diagnostic(), attrs, item_sp) {
63-
Some(stab) => {
63+
Some(mut stab) => {
6464
debug!("annotate: found {:?}", stab);
65+
// if parent is deprecated and we're not, inherit this by merging
66+
// deprecated_since and its reason.
67+
if let Some(parent_stab) = self.parent {
68+
if parent_stab.deprecated_since.is_some()
69+
&& stab.deprecated_since.is_none() {
70+
stab.deprecated_since = parent_stab.deprecated_since.clone();
71+
stab.reason = parent_stab.reason.clone();
72+
}
73+
}
74+
6575
let stab = self.tcx.intern_stability(stab);
6676
self.index.map.insert(local_def(id), Some(stab));
6777

0 commit comments

Comments
 (0)