Skip to content

Commit cbc4c83

Browse files
committed
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).
2 parents 8f02447 + 0931094 commit cbc4c83

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/librustc/middle/stability.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
614614
debug!("stability: \
615615
inspecting def_id={:?} span={:?} of stability={:?}", def_id, span, stability);
616616

617-
if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, .. }), ..})
617+
if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, since }), ..})
618618
= stability {
619619
if let Some(id) = id {
620-
lint_deprecated(def_id, id, Some(reason));
620+
if deprecation_in_effect(&since.as_str()) {
621+
lint_deprecated(def_id, id, Some(reason));
622+
}
621623
}
622624
}
623625

src/test/compile-fail/auxiliary/lint_stability.rs

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
1011
#![crate_name="lint_stability"]
1112
#![crate_type = "lib"]
1213
#![feature(staged_api)]
@@ -20,6 +21,10 @@ pub fn deprecated() {}
2021
#[rustc_deprecated(since = "1.0.0", reason = "text")]
2122
pub fn deprecated_text() {}
2223

24+
#[stable(feature = "test_feature", since = "1.0.0")]
25+
#[rustc_deprecated(since = "99.99.99", reason = "text")]
26+
pub fn deprecated_future() {}
27+
2328
#[unstable(feature = "test_feature", issue = "0")]
2429
#[rustc_deprecated(since = "1.0.0", reason = "text")]
2530
pub fn deprecated_unstable() {}

src/test/compile-fail/lint-stability.rs

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ mod cross_crate {
5050
<Foo>::trait_deprecated_text(&foo);
5151
<Foo as Trait>::trait_deprecated_text(&foo);
5252

53+
deprecated_future(); // Fine; no error.
54+
5355
deprecated_unstable();
5456
//~^ ERROR use of unstable library feature
5557
Trait::trait_deprecated_unstable(&foo);
@@ -218,6 +220,10 @@ mod this_crate {
218220
#[rustc_deprecated(since = "1.0.0", reason = "text")]
219221
pub fn deprecated_text() {}
220222

223+
#[stable(feature = "rust1", since = "1.0.0")]
224+
#[rustc_deprecated(since = "99.99.99", reason = "text")]
225+
pub fn deprecated_future() {}
226+
221227
#[unstable(feature = "test_feature", issue = "0")]
222228
pub fn unstable() {}
223229
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
@@ -338,6 +344,8 @@ mod this_crate {
338344
<Foo>::trait_deprecated_text(&foo);
339345
<Foo as Trait>::trait_deprecated_text(&foo);
340346

347+
deprecated_future();
348+
341349
unstable();
342350
foo.method_unstable();
343351
Foo::method_unstable(&foo);

0 commit comments

Comments
 (0)