Skip to content

Commit 105bd15

Browse files
committed
Address the review comments
1 parent e3ed7b0 commit 105bd15

File tree

7 files changed

+22
-62
lines changed

7 files changed

+22
-62
lines changed

src/librustc/middle/stability.rs

+4-59
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
171171
attr::mark_used(attr);
172172
self.tcx.sess.span_err(attr.span(), "stability attributes may not be used \
173173
outside of the standard library");
174-
} else if tag == "deprecated" {
175-
if !self.tcx.sess.features.borrow().deprecated {
176-
self.tcx.sess.span_err(attr.span(),
177-
"`#[deprecated]` attribute is unstable");
178-
fileline_help!(self.tcx.sess, attr.span(), "add #![feature(deprecated)] to \
179-
the crate features to enable");
180-
}
181174
}
182175
}
183176

@@ -687,68 +680,20 @@ pub fn lookup_deprecation<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Depre
687680

688681
fn lookup_stability_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> {
689682
debug!("lookup(id={:?})", id);
690-
691-
// is this definition the implementation of a trait method?
692-
match tcx.trait_item_of_item(id) {
693-
Some(ty::MethodTraitItemId(trait_method_id)) if trait_method_id != id => {
694-
debug!("lookup: trait_method_id={:?}", trait_method_id);
695-
return lookup_stability(tcx, trait_method_id)
696-
}
697-
_ => {}
698-
}
699-
700-
let item_stab = if id.is_local() {
683+
if id.is_local() {
701684
None // The stability cache is filled partially lazily
702685
} else {
703686
tcx.sess.cstore.stability(id).map(|st| tcx.intern_stability(st))
704-
};
705-
706-
item_stab.or_else(|| {
707-
if tcx.is_impl(id) {
708-
if let Some(trait_id) = tcx.trait_id_of_impl(id) {
709-
// FIXME (#18969): for the time being, simply use the
710-
// stability of the trait to determine the stability of any
711-
// unmarked impls for it. See FIXME above for more details.
712-
713-
debug!("lookup: trait_id={:?}", trait_id);
714-
return lookup_stability(tcx, trait_id);
715-
}
716-
}
717-
None
718-
})
687+
}
719688
}
720689

721690
fn lookup_deprecation_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Deprecation> {
722691
debug!("lookup(id={:?})", id);
723-
724-
// is this definition the implementation of a trait method?
725-
match tcx.trait_item_of_item(id) {
726-
Some(ty::MethodTraitItemId(trait_method_id)) if trait_method_id != id => {
727-
debug!("lookup: trait_method_id={:?}", trait_method_id);
728-
return lookup_deprecation(tcx, trait_method_id)
729-
}
730-
_ => {}
731-
}
732-
733-
let item_depr = if id.is_local() {
692+
if id.is_local() {
734693
None // The stability cache is filled partially lazily
735694
} else {
736695
tcx.sess.cstore.deprecation(id)
737-
};
738-
739-
item_depr.or_else(|| {
740-
if tcx.is_impl(id) {
741-
if let Some(trait_id) = tcx.trait_id_of_impl(id) {
742-
// FIXME (#18969): for the time being, simply use the
743-
// stability of the trait to determine the stability of any
744-
// unmarked impls for it. See FIXME above for more details.
745-
746-
debug!("lookup: trait_id={:?}", trait_id);
747-
return lookup_deprecation(tcx, trait_id);
748-
}
749-
}
750-
None
751-
})
696+
}
752697
}
753698

754699
/// Given the list of enabled features that were not language features (i.e. that

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ impl LateLintPass for MissingDebugImplementations {
575575
declare_lint! {
576576
DEPRECATED,
577577
Warn,
578-
"detects use of `#[deprecated]` or `#[rustc_deprecated]` items"
578+
"detects use of deprecated items"
579579
}
580580

581581
/// Checks for use of items with `#[deprecated]` or `#[rustc_deprecated]` attributes

src/libsyntax/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
380380
("must_use", Whitelisted, Ungated),
381381
("stable", Whitelisted, Ungated),
382382
("unstable", Whitelisted, Ungated),
383-
("deprecated", Whitelisted, Ungated),
383+
("deprecated", Normal, Gated("deprecated", "`#[deprecated]` attribute is unstable")),
384384

385385
("rustc_paren_sugar", Normal, Gated("unboxed_closures",
386386
"unboxed_closures are still evolving")),

src/test/auxiliary/deprecation-lint.rs

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pub trait Trait {
3131
fn trait_deprecated_text(&self) {}
3232
}
3333

34+
#[deprecated(since = "1.0.0", note = "text")]
35+
pub trait DeprecatedTrait { fn dummy(&self) { } }
36+
3437
impl Trait for MethodTester {}
3538

3639
#[deprecated(since = "1.0.0", note = "text")]

src/test/auxiliary/lint_stability.rs

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ impl Trait for MethodTester {}
9898
#[unstable(feature = "test_feature", issue = "0")]
9999
pub trait UnstableTrait { fn dummy(&self) { } }
100100

101+
#[stable(feature = "test_feature", since = "1.0.0")]
102+
#[rustc_deprecated(since = "1.0.0", reason = "text")]
103+
pub trait DeprecatedTrait {
104+
#[stable(feature = "test_feature", since = "1.0.0")] fn dummy(&self) { }
105+
}
106+
101107
#[stable(feature = "test_feature", since = "1.0.0")]
102108
#[rustc_deprecated(since = "1.0.0", reason = "text")]
103109
pub struct DeprecatedStruct {

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

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ mod cross_crate {
7878
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
7979
}
8080

81+
struct S;
82+
83+
impl DeprecatedTrait for S {} //~ ERROR use of deprecated item: text
84+
trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item: text
85+
8186
pub fn foo() {
8287
let x = Stable {
8388
override2: 3,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ mod cross_crate {
227227
struct S;
228228

229229
impl UnstableTrait for S { } //~ ERROR use of unstable library feature
230-
230+
impl DeprecatedTrait for S {} //~ ERROR use of deprecated item: text
231231
trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable library feature
232+
trait LocalTrait2 : DeprecatedTrait { } //~ ERROR use of deprecated item: text
232233

233234
impl Trait for S {
234235
fn trait_stable(&self) {}

0 commit comments

Comments
 (0)