Skip to content

Commit 0c73b25

Browse files
authored
Rollup merge of #94982 - skippy10110:deprecated_safe, r=Dylan-DPC
Add deprecated_safe feature gate and attribute, cc #94978
2 parents 270a41c + e4f1179 commit 0c73b25

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

compiler/rustc_feature/src/active.rs

+2
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ declare_features! (
364364
(active, default_alloc_error_handler, "1.48.0", Some(66741), None),
365365
/// Allows default type parameters to influence type inference.
366366
(active, default_type_parameter_fallback, "1.3.0", Some(27336), None),
367+
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
368+
(active, deprecated_safe, "1.61.0", Some(94978), None),
367369
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
368370
(active, deprecated_suggestion, "1.61.0", Some(94785), None),
369371
/// Allows `#[derive(Default)]` and `#[default]` on enums.

compiler/rustc_feature/src/builtin_attrs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,11 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
452452
"`default_method_body_is_const` is a temporary placeholder for declaring default bodies \
453453
as `const`, which may be removed or renamed in the future."
454454
),
455+
// lang-team MCP 147
456+
gated!(
457+
deprecated_safe, Normal, template!(List: r#"since = "version", note = "...""#), ErrorFollowing,
458+
experimental!(deprecated_safe),
459+
),
455460

456461
// ==========================================================================
457462
// Internal attributes: Stability, deprecation, and unsafe:

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ symbols! {
563563
delay_span_bug_from_inside_query,
564564
deny,
565565
deprecated,
566+
deprecated_safe,
566567
deprecated_suggestion,
567568
deref,
568569
deref_method,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[deprecated_safe(since = "TBD", note = "...")] //~ ERROR: the `#[deprecated_safe]` attribute is an experimental feature
2+
unsafe fn deprecated_safe_fn() {}
3+
4+
#[deprecated_safe(since = "TBD", note = "...")] //~ ERROR: the `#[deprecated_safe]` attribute is an experimental feature
5+
unsafe trait DeprecatedSafeTrait {}
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0658]: the `#[deprecated_safe]` attribute is an experimental feature
2+
--> $DIR/feature-gate-deprecated_safe.rs:1:1
3+
|
4+
LL | #[deprecated_safe(since = "TBD", note = "...")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #94978 <https://github.com./rust-lang/rust/issues/94978> for more information
8+
= help: add `#![feature(deprecated_safe)]` to the crate attributes to enable
9+
10+
error[E0658]: the `#[deprecated_safe]` attribute is an experimental feature
11+
--> $DIR/feature-gate-deprecated_safe.rs:4:1
12+
|
13+
LL | #[deprecated_safe(since = "TBD", note = "...")]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: see issue #94978 <https://github.com./rust-lang/rust/issues/94978> for more information
17+
= help: add `#![feature(deprecated_safe)]` to the crate attributes to enable
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)