Address the review comments
This commit is contained in:
@@ -171,13 +171,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
||||
attr::mark_used(attr);
|
||||
self.tcx.sess.span_err(attr.span(), "stability attributes may not be used \
|
||||
outside of the standard library");
|
||||
} else if tag == "deprecated" {
|
||||
if !self.tcx.sess.features.borrow().deprecated {
|
||||
self.tcx.sess.span_err(attr.span(),
|
||||
"`#[deprecated]` attribute is unstable");
|
||||
fileline_help!(self.tcx.sess, attr.span(), "add #![feature(deprecated)] to \
|
||||
the crate features to enable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,69 +680,21 @@ pub fn lookup_deprecation<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Depre
|
||||
|
||||
fn lookup_stability_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> {
|
||||
debug!("lookup(id={:?})", id);
|
||||
|
||||
// is this definition the implementation of a trait method?
|
||||
match tcx.trait_item_of_item(id) {
|
||||
Some(ty::MethodTraitItemId(trait_method_id)) if trait_method_id != id => {
|
||||
debug!("lookup: trait_method_id={:?}", trait_method_id);
|
||||
return lookup_stability(tcx, trait_method_id)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let item_stab = if id.is_local() {
|
||||
if id.is_local() {
|
||||
None // The stability cache is filled partially lazily
|
||||
} else {
|
||||
tcx.sess.cstore.stability(id).map(|st| tcx.intern_stability(st))
|
||||
};
|
||||
|
||||
item_stab.or_else(|| {
|
||||
if tcx.is_impl(id) {
|
||||
if let Some(trait_id) = tcx.trait_id_of_impl(id) {
|
||||
// FIXME (#18969): for the time being, simply use the
|
||||
// stability of the trait to determine the stability of any
|
||||
// unmarked impls for it. See FIXME above for more details.
|
||||
|
||||
debug!("lookup: trait_id={:?}", trait_id);
|
||||
return lookup_stability(tcx, trait_id);
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
fn lookup_deprecation_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Deprecation> {
|
||||
debug!("lookup(id={:?})", id);
|
||||
|
||||
// is this definition the implementation of a trait method?
|
||||
match tcx.trait_item_of_item(id) {
|
||||
Some(ty::MethodTraitItemId(trait_method_id)) if trait_method_id != id => {
|
||||
debug!("lookup: trait_method_id={:?}", trait_method_id);
|
||||
return lookup_deprecation(tcx, trait_method_id)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let item_depr = if id.is_local() {
|
||||
if id.is_local() {
|
||||
None // The stability cache is filled partially lazily
|
||||
} else {
|
||||
tcx.sess.cstore.deprecation(id)
|
||||
};
|
||||
|
||||
item_depr.or_else(|| {
|
||||
if tcx.is_impl(id) {
|
||||
if let Some(trait_id) = tcx.trait_id_of_impl(id) {
|
||||
// FIXME (#18969): for the time being, simply use the
|
||||
// stability of the trait to determine the stability of any
|
||||
// unmarked impls for it. See FIXME above for more details.
|
||||
|
||||
debug!("lookup: trait_id={:?}", trait_id);
|
||||
return lookup_deprecation(tcx, trait_id);
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
/// Given the list of enabled features that were not language features (i.e. that
|
||||
/// were expected to be library features), and the list of features used from
|
||||
|
||||
@@ -575,7 +575,7 @@ impl LateLintPass for MissingDebugImplementations {
|
||||
declare_lint! {
|
||||
DEPRECATED,
|
||||
Warn,
|
||||
"detects use of `#[deprecated]` or `#[rustc_deprecated]` items"
|
||||
"detects use of deprecated items"
|
||||
}
|
||||
|
||||
/// Checks for use of items with `#[deprecated]` or `#[rustc_deprecated]` attributes
|
||||
|
||||
@@ -380,7 +380,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
|
||||
("must_use", Whitelisted, Ungated),
|
||||
("stable", Whitelisted, Ungated),
|
||||
("unstable", Whitelisted, Ungated),
|
||||
("deprecated", Whitelisted, Ungated),
|
||||
("deprecated", Normal, Gated("deprecated", "`#[deprecated]` attribute is unstable")),
|
||||
|
||||
("rustc_paren_sugar", Normal, Gated("unboxed_closures",
|
||||
"unboxed_closures are still evolving")),
|
||||
|
||||
@@ -31,6 +31,9 @@ pub trait Trait {
|
||||
fn trait_deprecated_text(&self) {}
|
||||
}
|
||||
|
||||
#[deprecated(since = "1.0.0", note = "text")]
|
||||
pub trait DeprecatedTrait { fn dummy(&self) { } }
|
||||
|
||||
impl Trait for MethodTester {}
|
||||
|
||||
#[deprecated(since = "1.0.0", note = "text")]
|
||||
|
||||
@@ -98,6 +98,12 @@ impl Trait for MethodTester {}
|
||||
#[unstable(feature = "test_feature", issue = "0")]
|
||||
pub trait UnstableTrait { fn dummy(&self) { } }
|
||||
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.0.0", reason = "text")]
|
||||
pub trait DeprecatedTrait {
|
||||
#[stable(feature = "test_feature", since = "1.0.0")] fn dummy(&self) { }
|
||||
}
|
||||
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.0.0", reason = "text")]
|
||||
pub struct DeprecatedStruct {
|
||||
|
||||
@@ -78,6 +78,11 @@ mod cross_crate {
|
||||
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl DeprecatedTrait for S {} //~ ERROR use of deprecated item: text
|
||||
trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item: text
|
||||
|
||||
pub fn foo() {
|
||||
let x = Stable {
|
||||
override2: 3,
|
||||
|
||||
@@ -227,8 +227,9 @@ mod cross_crate {
|
||||
struct S;
|
||||
|
||||
impl UnstableTrait for S { } //~ ERROR use of unstable library feature
|
||||
|
||||
impl DeprecatedTrait for S {} //~ ERROR use of deprecated item: text
|
||||
trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable library feature
|
||||
trait LocalTrait2 : DeprecatedTrait { } //~ ERROR use of deprecated item: text
|
||||
|
||||
impl Trait for S {
|
||||
fn trait_stable(&self) {}
|
||||
|
||||
Reference in New Issue
Block a user