Support future deprecation for rustc_deprecated

This commit is contained in:
varkor 2018-06-21 14:37:35 +01:00
parent cca43a7f97
commit 09310947be
3 changed files with 17 additions and 2 deletions

View file

@ -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));
}
}
}

View 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() {}

View file

@ -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);