Skip to content

Commit 3737d4d

Browse files
committed
Do not apply future deprecation warning for #[deprecated]
1 parent 652ae3f commit 3737d4d

File tree

5 files changed

+67
-84
lines changed

5 files changed

+67
-84
lines changed

src/librustc/middle/stability.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -598,37 +598,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
598598
// Deprecated attributes apply in-crate and cross-crate.
599599
if let Some(id) = id {
600600
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
601-
// If the deprecation is scheduled for a future Rust
602-
// version, then we should display no warning message.
603-
let deprecated_in_future_version = if let Some(sym) = depr_entry.attr.since {
604-
let since = sym.as_str();
605-
if !deprecation_in_effect(&since) {
606-
Some(since)
607-
} else {
608-
None
609-
}
610-
} else {
611-
None
612-
};
613-
614601
let parent_def_id = self.hir().local_def_id(self.hir().get_parent(id));
615602
let skip = self.lookup_deprecation_entry(parent_def_id)
616603
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
617604

618-
if let Some(since) = deprecated_in_future_version {
619-
let path = self.item_path_str(def_id);
620-
let message = format!("use of item '{}' \
621-
that will be deprecated in future version {}",
622-
path,
623-
since);
624-
625-
lint_deprecated(def_id,
626-
id,
627-
depr_entry.attr.note,
628-
None,
629-
&message,
630-
lint::builtin::DEPRECATED_IN_FUTURE);
631-
} else if !skip {
605+
if !skip {
632606
let path = self.item_path_str(def_id);
633607
let message = format!("use of deprecated item '{}'", path);
634608
lint_deprecated(def_id,
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// ignore-tidy-linelength
22

3+
// run-pass
4+
35
#![deny(deprecated_in_future)]
46

57
#[deprecated(since = "99.99.99", note = "text")]
68
pub fn deprecated_future() {}
79

810
fn test() {
9-
deprecated_future(); //~ ERROR use of item 'deprecated_future' that will be deprecated in future version 99.99.99: text
11+
deprecated_future(); // ok; deprecated_in_future only applies to rustc_deprecated
1012
}
1113

1214
fn main() {}
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
error: use of item 'deprecated_future' that will be deprecated in future version 99.99.99: text
2-
--> $DIR/deprecation-in-future.rs:9:5
1+
warning: use of deprecated item 'deprecated_future': text
2+
--> $DIR/deprecation-in-future.rs:11:5
33
|
4-
LL | deprecated_future(); //~ ERROR use of item 'deprecated_future' that will be deprecated in future version 99.99.99: text
4+
LL | deprecated_future(); // ok; deprecated_in_future only applies to rustc_deprecated
55
| ^^^^^^^^^^^^^^^^^
66
|
7-
note: lint level defined here
8-
--> $DIR/deprecation-in-future.rs:3:9
9-
|
10-
LL | #![deny(deprecated_in_future)]
11-
| ^^^^^^^^^^^^^^^^^^^^
12-
13-
error: aborting due to previous error
7+
= note: #[warn(deprecated)] on by default
148

src/test/ui/deprecation/deprecation-lint.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ mod this_crate {
261261
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
262262
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
263263

264-
deprecated_future(); // Fine; no error.
265-
deprecated_future_text(); // Fine; no error.
264+
// Future deprecations are only permitted for rustc_deprecated.
265+
deprecated_future(); //~ ERROR use of deprecated item
266+
deprecated_future_text(); //~ ERROR use of deprecated item
266267

267268
let _ = DeprecatedStruct {
268269
//~^ ERROR use of deprecated item 'this_crate::DeprecatedStruct': text

0 commit comments

Comments
 (0)