]> git.lizzy.rs Git - rust.git/commitdiff
WIP inherited deprecation fixes #26040
authorAlexis Beingessner <a.beingessner@gmail.com>
Sat, 6 Jun 2015 22:52:28 +0000 (15:52 -0700)
committerAlexis Beingessner <a.beingessner@gmail.com>
Thu, 11 Jun 2015 17:49:28 +0000 (10:49 -0700)
src/librustc/middle/stability.rs

index b29e40d2d5ec61cbbd3596ca82dbbdbf306f11fb..5d092167d5ada08695087b3060e4ad6d6c1463c3 100644 (file)
@@ -60,8 +60,18 @@ fn annotate<F>(&mut self, id: NodeId, use_parent: bool,
         if self.index.staged_api[&ast::LOCAL_CRATE] {
             debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
             match attr::find_stability(self.tcx.sess.diagnostic(), attrs, item_sp) {
-                Some(stab) => {
+                Some(mut stab) => {
                     debug!("annotate: found {:?}", stab);
+                    // if parent is deprecated and we're not, inherit this by merging
+                    // deprecated_since and its reason.
+                    if let Some(parent_stab) = self.parent {
+                        if parent_stab.deprecated_since.is_some()
+                        && stab.deprecated_since.is_none() {
+                            stab.deprecated_since = parent_stab.deprecated_since.clone();
+                            stab.reason = parent_stab.reason.clone();
+                        }
+                    }
+
                     let stab = self.tcx.intern_stability(stab);
                     self.index.map.insert(local_def(id), Some(stab));