Enable deprecation lint on crate-local items
Previously the lint considered cross-crate items only. That's appropriate for unstable and experimental levels, but not for deprecation. Closes #16409 Due to deny(deprecation), this is a: [breaking-change]
This commit is contained in:
parent
e2273d9456
commit
0b5204f55e
@ -1479,20 +1479,20 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
|
||||
_ => return
|
||||
};
|
||||
|
||||
// stability attributes are promises made across crates; do not
|
||||
// check anything for crate-local usage.
|
||||
if ast_util::is_local(id) { return }
|
||||
|
||||
let stability = stability::lookup(cx.tcx, id);
|
||||
let cross_crate = !ast_util::is_local(id);
|
||||
|
||||
// stability attributes are promises made across crates; only
|
||||
// check DEPRECATED for crate-local usage.
|
||||
let (lint, label) = match stability {
|
||||
// no stability attributes == Unstable
|
||||
None => (UNSTABLE, "unmarked"),
|
||||
Some(attr::Stability { level: attr::Unstable, .. }) =>
|
||||
(UNSTABLE, "unstable"),
|
||||
Some(attr::Stability { level: attr::Experimental, .. }) =>
|
||||
(EXPERIMENTAL, "experimental"),
|
||||
None if cross_crate => (UNSTABLE, "unmarked"),
|
||||
Some(attr::Stability { level: attr::Unstable, .. }) if cross_crate =>
|
||||
(UNSTABLE, "unstable"),
|
||||
Some(attr::Stability { level: attr::Experimental, .. }) if cross_crate =>
|
||||
(EXPERIMENTAL, "experimental"),
|
||||
Some(attr::Stability { level: attr::Deprecated, .. }) =>
|
||||
(DEPRECATED, "deprecated"),
|
||||
(DEPRECATED, "deprecated"),
|
||||
_ => return
|
||||
};
|
||||
|
||||
|
@ -329,19 +329,19 @@ pub enum Enum {
|
||||
pub struct LockedTupleStruct(int);
|
||||
|
||||
fn test() {
|
||||
// None of the following should generate errors, because
|
||||
// stability attributes now have meaning only *across* crates,
|
||||
// not within a single crate.
|
||||
// Only the deprecated cases of the following should generate
|
||||
// errors, because other stability attributes now have meaning
|
||||
// only *across* crates, not within a single crate.
|
||||
|
||||
let foo = MethodTester;
|
||||
|
||||
deprecated();
|
||||
foo.method_deprecated();
|
||||
foo.trait_deprecated();
|
||||
deprecated(); //~ ERROR use of deprecated item
|
||||
foo.method_deprecated(); //~ ERROR use of deprecated item
|
||||
foo.trait_deprecated(); //~ ERROR use of deprecated item
|
||||
|
||||
deprecated_text();
|
||||
foo.method_deprecated_text();
|
||||
foo.trait_deprecated_text();
|
||||
deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
|
||||
experimental();
|
||||
foo.method_experimental();
|
||||
@ -387,8 +387,7 @@ fn test() {
|
||||
foo.method_locked_text();
|
||||
foo.trait_locked_text();
|
||||
|
||||
|
||||
let _ = DeprecatedStruct { i: 0 };
|
||||
let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item
|
||||
let _ = ExperimentalStruct { i: 0 };
|
||||
let _ = UnstableStruct { i: 0 };
|
||||
let _ = UnmarkedStruct { i: 0 };
|
||||
@ -396,7 +395,7 @@ fn test() {
|
||||
let _ = FrozenStruct { i: 0 };
|
||||
let _ = LockedStruct { i: 0 };
|
||||
|
||||
let _ = DeprecatedUnitStruct;
|
||||
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
|
||||
let _ = ExperimentalUnitStruct;
|
||||
let _ = UnstableUnitStruct;
|
||||
let _ = UnmarkedUnitStruct;
|
||||
@ -404,7 +403,7 @@ fn test() {
|
||||
let _ = FrozenUnitStruct;
|
||||
let _ = LockedUnitStruct;
|
||||
|
||||
let _ = DeprecatedVariant;
|
||||
let _ = DeprecatedVariant; //~ ERROR use of deprecated item
|
||||
let _ = ExperimentalVariant;
|
||||
let _ = UnstableVariant;
|
||||
let _ = UnmarkedVariant;
|
||||
@ -412,7 +411,7 @@ fn test() {
|
||||
let _ = FrozenVariant;
|
||||
let _ = LockedVariant;
|
||||
|
||||
let _ = DeprecatedTupleStruct (1);
|
||||
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
|
||||
let _ = ExperimentalTupleStruct (1);
|
||||
let _ = UnstableTupleStruct (1);
|
||||
let _ = UnmarkedTupleStruct (1);
|
||||
@ -422,8 +421,8 @@ fn test() {
|
||||
}
|
||||
|
||||
fn test_method_param<F: Trait>(foo: F) {
|
||||
foo.trait_deprecated();
|
||||
foo.trait_deprecated_text();
|
||||
foo.trait_deprecated(); //~ ERROR use of deprecated item
|
||||
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
foo.trait_experimental();
|
||||
foo.trait_experimental_text();
|
||||
foo.trait_unstable();
|
||||
@ -433,8 +432,8 @@ fn test_method_param<F: Trait>(foo: F) {
|
||||
}
|
||||
|
||||
fn test_method_object(foo: &Trait) {
|
||||
foo.trait_deprecated();
|
||||
foo.trait_deprecated_text();
|
||||
foo.trait_deprecated(); //~ ERROR use of deprecated item
|
||||
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
foo.trait_experimental();
|
||||
foo.trait_experimental_text();
|
||||
foo.trait_unstable();
|
||||
|
Loading…
Reference in New Issue
Block a user