Skip to content

Commit

Permalink
Support future deprecation for rustc_deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Jun 21, 2018
1 parent cca43a7 commit 0931094
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/test/compile-fail/auxiliary/lint_stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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() {}
Expand Down
8 changes: 8 additions & 0 deletions src/test/compile-fail/lint-stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0931094

Please sign in to comment.