about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-06-22 19:55:30 +0000
committerbors <bors@rust-lang.org>2018-06-22 19:55:30 +0000
commitcbc4c8380fb92a719ae9be40f9da44ca7e3e2f3f (patch)
tree53f3e3c2b9cfb12af5e74a8a10c8f4d08e306c47 /src
parent8f024479d4e702647e7a772e06f77391abcfa571 (diff)
parent09310947be113f4ccae0f6c5a24f6ddf4b611a72 (diff)
downloadrust-cbc4c8380fb92a719ae9be40f9da44ca7e3e2f3f.tar.gz
rust-cbc4c8380fb92a719ae9be40f9da44ca7e3e2f3f.zip
Auto merge of #51681 - varkor:rustc_deprecated-future-deprecation, r=petrochenkov
Support future deprecation for rustc_deprecated

Follow-up to #49179 to allow `since` parameters to be set to future versions of Rust and correspondingly to not be treated as deprecated until that version. This is required for #30459 to be completed (though we'll need to wait until this hits beta).
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/stability.rs6
-rw-r--r--src/test/compile-fail/auxiliary/lint_stability.rs5
-rw-r--r--src/test/compile-fail/lint-stability.rs8
3 files changed, 17 insertions, 2 deletions
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs
index d6a7d5e8472..4cdc9fdddbf 100644
--- a/src/librustc/middle/stability.rs
+++ b/src/librustc/middle/stability.rs
@@ -614,10 +614,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
         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));
+                }
             }
         }
 
diff --git a/src/test/compile-fail/auxiliary/lint_stability.rs b/src/test/compile-fail/auxiliary/lint_stability.rs
index 5e3cb606ce0..07e80b61cd0 100644
--- a/src/test/compile-fail/auxiliary/lint_stability.rs
+++ b/src/test/compile-fail/auxiliary/lint_stability.rs
@@ -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() {}
diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs
index 49a52204295..bd390108bd8 100644
--- a/src/test/compile-fail/lint-stability.rs
+++ b/src/test/compile-fail/lint-stability.rs
@@ -50,6 +50,8 @@ mod cross_crate {
         <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 @@ mod this_crate {
     #[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 @@ mod this_crate {
         <Foo>::trait_deprecated_text(&foo);
         <Foo as Trait>::trait_deprecated_text(&foo);
 
+        deprecated_future();
+
         unstable();
         foo.method_unstable();
         Foo::method_unstable(&foo);