]> git.lizzy.rs Git - rust.git/commitdiff
Support future deprecation for rustc_deprecated
authorvarkor <github@varkor.com>
Thu, 21 Jun 2018 13:37:35 +0000 (14:37 +0100)
committervarkor <github@varkor.com>
Thu, 21 Jun 2018 15:00:32 +0000 (16:00 +0100)
src/librustc/middle/stability.rs
src/test/compile-fail/auxiliary/lint_stability.rs
src/test/compile-fail/lint-stability.rs

index d6a7d5e8472ac086dab3b6dec23b6cc37664f8cd..4cdc9fdddbf80b1176de05bdd44b9a26ab91315a 100644 (file)
@@ -614,10 +614,12 @@ pub fn eval_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) -> Ev
         debug!("stability: \
                 inspecting def_id={:?} span={:?} of stability={:?}", def_id, span, stability);
 
-        if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, .. }), ..})
+        if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, since }), ..})
                 = stability {
             if let Some(id) = id {
-                lint_deprecated(def_id, id, Some(reason));
+                if deprecation_in_effect(&since.as_str()) {
+                    lint_deprecated(def_id, id, Some(reason));
+                }
             }
         }
 
index 5e3cb606ce0371f258c77d2ec1576f398f29addd..07e80b61cd0a69cc764a016b88c15c940a9efe3d 100644 (file)
@@ -7,6 +7,7 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+
 #![crate_name="lint_stability"]
 #![crate_type = "lib"]
 #![feature(staged_api)]
@@ -20,6 +21,10 @@ pub fn deprecated() {}
 #[rustc_deprecated(since = "1.0.0", reason = "text")]
 pub fn deprecated_text() {}
 
+#[stable(feature = "test_feature", since = "1.0.0")]
+#[rustc_deprecated(since = "99.99.99", reason = "text")]
+pub fn deprecated_future() {}
+
 #[unstable(feature = "test_feature", issue = "0")]
 #[rustc_deprecated(since = "1.0.0", reason = "text")]
 pub fn deprecated_unstable() {}
index 49a52204295e505aa3e6b8762c6c7a8ce02974fe..bd390108bd8f3c40468fc1e122bae926a345f8c3 100644 (file)
@@ -50,6 +50,8 @@ fn test() {
         <Foo>::trait_deprecated_text(&foo);
         <Foo as Trait>::trait_deprecated_text(&foo);
 
+        deprecated_future(); // Fine; no error.
+
         deprecated_unstable();
         //~^ ERROR use of unstable library feature
         Trait::trait_deprecated_unstable(&foo);
@@ -218,6 +220,10 @@ pub fn deprecated() {}
     #[rustc_deprecated(since = "1.0.0", reason = "text")]
     pub fn deprecated_text() {}
 
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[rustc_deprecated(since = "99.99.99", reason = "text")]
+    pub fn deprecated_future() {}
+
     #[unstable(feature = "test_feature", issue = "0")]
     pub fn unstable() {}
     #[unstable(feature = "test_feature", reason = "text", issue = "0")]
@@ -338,6 +344,8 @@ fn test() {
         <Foo>::trait_deprecated_text(&foo);
         <Foo as Trait>::trait_deprecated_text(&foo);
 
+        deprecated_future();
+
         unstable();
         foo.method_unstable();
         Foo::method_unstable(&foo);