Skip to content

Commit 38478ea

Browse files
committed
Permit #[deprecated] in stdlib
1 parent 5636655 commit 38478ea

33 files changed

+166
-364
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

-8
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
437437
)
438438
.emit();
439439
}
440-
} else {
441-
// FIXME(jhpratt) remove this after the two attributes are merged
442-
if attr.has_name(sym::deprecated) {
443-
self.sess
444-
.struct_span_err(attr.span, "`#[deprecated]` cannot be used in staged API")
445-
.span_label(attr.span, "use `#[rustc_deprecated]` instead")
446-
.emit();
447-
}
448440
}
449441
}
450442

compiler/rustc_attr/src/builtin.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ where
665665
{
666666
let mut depr: Option<(Deprecation, Span)> = None;
667667
let diagnostic = &sess.parse_sess.span_diagnostic;
668+
let is_rustc = sess.features_untracked().staged_api;
668669

669670
'outer: for attr in attrs_iter {
670671
if !(attr.has_name(sym::deprecated) || attr.has_name(sym::rustc_deprecated)) {
@@ -790,7 +791,7 @@ where
790791
}
791792
}
792793

793-
if attr.has_name(sym::rustc_deprecated) {
794+
if is_rustc {
794795
if since.is_none() {
795796
handle_errors(&sess.parse_sess, attr.span, AttrError::MissingSince);
796797
continue;
@@ -802,8 +803,10 @@ where
802803
}
803804
}
804805

805-
let is_since_rustc_version = attr.has_name(sym::rustc_deprecated);
806-
depr = Some((Deprecation { since, note, suggestion, is_since_rustc_version }, attr.span));
806+
depr = Some((
807+
Deprecation { since, note, suggestion, is_since_rustc_version: is_rustc },
808+
attr.span,
809+
));
807810
}
808811

809812
depr

compiler/rustc_passes/src/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
202202
self.tcx.sess,
203203
*span,
204204
E0549,
205-
"rustc_deprecated attribute must be paired with \
205+
"deprecated attribute must be paired with \
206206
either stable or unstable attribute"
207207
)
208208
.emit();

src/test/ui/deprecation/deprecation-in-staged-api.rs

-4
This file was deleted.

src/test/ui/deprecation/deprecation-in-staged-api.stderr

-8
This file was deleted.

src/test/ui/deprecation/rustc_deprecation-in-future.rs renamed to src/test/ui/deprecation/staged-deprecation-in-future.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
#![stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")]
66

7-
#[rustc_deprecated(since = "99.99.99", note = "effectively never")]
7+
#[deprecated(since = "99.99.99", note = "effectively never")]
88
#[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")]
99
pub struct S1;
1010

11-
#[rustc_deprecated(since = "TBD", note = "literally never")]
11+
#[deprecated(since = "TBD", note = "literally never")]
1212
#[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")]
1313
pub struct S2;
1414

src/test/ui/deprecation/rustc_deprecation-in-future.stderr renamed to src/test/ui/deprecation/staged-deprecation-in-future.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: use of unit struct `S1` that will be deprecated in future version 99.99.99: effectively never
2-
--> $DIR/rustc_deprecation-in-future.rs:16:13
2+
--> $DIR/staged-deprecation-in-future.rs:16:13
33
|
44
LL | let _ = S1;
55
| ^^
66
|
77
note: the lint level is defined here
8-
--> $DIR/rustc_deprecation-in-future.rs:1:9
8+
--> $DIR/staged-deprecation-in-future.rs:1:9
99
|
1010
LL | #![deny(deprecated_in_future)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

1313
error: use of unit struct `S2` that will be deprecated in a future Rust version: literally never
14-
--> $DIR/rustc_deprecation-in-future.rs:17:13
14+
--> $DIR/staged-deprecation-in-future.rs:17:13
1515
|
1616
LL | let _ = S2;
1717
| ^^

src/test/ui/deprecation/suggestion.fixed

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
struct Foo;
1212

1313
impl Foo {
14-
#[rustc_deprecated(
14+
#[deprecated(
1515
since = "1.0.0",
16-
reason = "replaced by `replacement`",
16+
note = "replaced by `replacement`",
1717
suggestion = "replacement",
1818
)]
1919
#[stable(since = "1.0.0", feature = "test")]
@@ -23,9 +23,9 @@ impl Foo {
2323
}
2424

2525
mod bar {
26-
#[rustc_deprecated(
26+
#[deprecated(
2727
since = "1.0.0",
28-
reason = "replaced by `replacement`",
28+
note = "replaced by `replacement`",
2929
suggestion = "replacement",
3030
)]
3131
#[stable(since = "1.0.0", feature = "test")]

src/test/ui/deprecation/suggestion.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
struct Foo;
1212

1313
impl Foo {
14-
#[rustc_deprecated(
14+
#[deprecated(
1515
since = "1.0.0",
16-
reason = "replaced by `replacement`",
16+
note = "replaced by `replacement`",
1717
suggestion = "replacement",
1818
)]
1919
#[stable(since = "1.0.0", feature = "test")]
@@ -23,9 +23,9 @@ impl Foo {
2323
}
2424

2525
mod bar {
26-
#[rustc_deprecated(
26+
#[deprecated(
2727
since = "1.0.0",
28-
reason = "replaced by `replacement`",
28+
note = "replaced by `replacement`",
2929
suggestion = "replacement",
3030
)]
3131
#[stable(since = "1.0.0", feature = "test")]

src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.rs

-43
This file was deleted.

src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.stderr

-94
This file was deleted.

src/test/ui/issues/issue-17337.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct Foo;
77

88
impl Foo {
99
#[unstable(feature = "unstable_test_feature", issue = "none")]
10-
#[rustc_deprecated(since = "1.0.0", note = "text")]
10+
#[deprecated(since = "1.0.0", note = "text")]
1111
fn foo(self) {}
1212
}
1313

src/test/ui/lint/auxiliary/inherited_stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod stable_mod {
2020
#[unstable(feature = "unstable_test_feature", issue = "none")]
2121
pub mod unstable_mod {
2222
#[stable(feature = "stable_test_feature", since = "1.0.0")]
23-
#[rustc_deprecated(since = "1.0.0", note = "text")]
23+
#[deprecated(since = "1.0.0", note = "text")]
2424
pub fn deprecated() {}
2525

2626
pub fn unstable() {}

src/test/ui/lint/auxiliary/lint_output_format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![unstable(feature = "unstable_test_feature", issue = "none")]
55

66
#[stable(feature = "stable_test_feature", since = "1.0.0")]
7-
#[rustc_deprecated(since = "1.0.0", note = "text")]
7+
#[deprecated(since = "1.0.0", note = "text")]
88
pub fn foo() -> usize {
99
20
1010
}

0 commit comments

Comments
 (0)