Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #94802

Merged
merged 13 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Permit #[deprecated] in stdlib
  • Loading branch information
jhpratt committed Mar 9, 2022
commit 38478ea0cda8c7e2a4e8e841f97910bcb6d08ef3
8 changes: 0 additions & 8 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
)
.emit();
}
} else {
// FIXME(jhpratt) remove this after the two attributes are merged
if attr.has_name(sym::deprecated) {
self.sess
.struct_span_err(attr.span, "`#[deprecated]` cannot be used in staged API")
.span_label(attr.span, "use `#[rustc_deprecated]` instead")
.emit();
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ where
{
let mut depr: Option<(Deprecation, Span)> = None;
let diagnostic = &sess.parse_sess.span_diagnostic;
let is_rustc = sess.features_untracked().staged_api;

'outer: for attr in attrs_iter {
if !(attr.has_name(sym::deprecated) || attr.has_name(sym::rustc_deprecated)) {
Expand Down Expand Up @@ -790,7 +791,7 @@ where
}
}

if attr.has_name(sym::rustc_deprecated) {
if is_rustc {
if since.is_none() {
handle_errors(&sess.parse_sess, attr.span, AttrError::MissingSince);
continue;
Expand All @@ -802,8 +803,10 @@ where
}
}

let is_since_rustc_version = attr.has_name(sym::rustc_deprecated);
depr = Some((Deprecation { since, note, suggestion, is_since_rustc_version }, attr.span));
depr = Some((
Deprecation { since, note, suggestion, is_since_rustc_version: is_rustc },
attr.span,
));
}

depr
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
self.tcx.sess,
*span,
E0549,
"rustc_deprecated attribute must be paired with \
"deprecated attribute must be paired with \
either stable or unstable attribute"
)
.emit();
Expand Down
4 changes: 0 additions & 4 deletions src/test/ui/deprecation/deprecation-in-staged-api.rs

This file was deleted.

8 changes: 0 additions & 8 deletions src/test/ui/deprecation/deprecation-in-staged-api.stderr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

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

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: use of unit struct `S1` that will be deprecated in future version 99.99.99: effectively never
--> $DIR/rustc_deprecation-in-future.rs:16:13
--> $DIR/staged-deprecation-in-future.rs:16:13
|
LL | let _ = S1;
| ^^
|
note: the lint level is defined here
--> $DIR/rustc_deprecation-in-future.rs:1:9
--> $DIR/staged-deprecation-in-future.rs:1:9
|
LL | #![deny(deprecated_in_future)]
| ^^^^^^^^^^^^^^^^^^^^

error: use of unit struct `S2` that will be deprecated in a future Rust version: literally never
--> $DIR/rustc_deprecation-in-future.rs:17:13
--> $DIR/staged-deprecation-in-future.rs:17:13
|
LL | let _ = S2;
| ^^
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/deprecation/suggestion.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
struct Foo;

impl Foo {
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "replaced by `replacement`",
note = "replaced by `replacement`",
suggestion = "replacement",
)]
#[stable(since = "1.0.0", feature = "test")]
Expand All @@ -23,9 +23,9 @@ impl Foo {
}

mod bar {
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "replaced by `replacement`",
note = "replaced by `replacement`",
suggestion = "replacement",
)]
#[stable(since = "1.0.0", feature = "test")]
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/deprecation/suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
struct Foo;

impl Foo {
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "replaced by `replacement`",
note = "replaced by `replacement`",
suggestion = "replacement",
)]
#[stable(since = "1.0.0", feature = "test")]
Expand All @@ -23,9 +23,9 @@ impl Foo {
}

mod bar {
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "replaced by `replacement`",
note = "replaced by `replacement`",
suggestion = "replacement",
)]
#[stable(since = "1.0.0", feature = "test")]
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-17337.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct Foo;

impl Foo {
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
#[deprecated(since = "1.0.0", note = "text")]
fn foo(self) {}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/auxiliary/inherited_stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod stable_mod {
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub mod unstable_mod {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
#[deprecated(since = "1.0.0", note = "text")]
pub fn deprecated() {}

pub fn unstable() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/auxiliary/lint_output_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![unstable(feature = "unstable_test_feature", issue = "none")]

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
#[deprecated(since = "1.0.0", note = "text")]
pub fn foo() -> usize {
20
}
Expand Down
Loading