Rollup merge of #93658 - cchiw:issue-77443-fix, r=joshtriplett

Stabilize `#[cfg(panic = "...")]`

[Stabilization PR](https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr) for #77443
This commit is contained in:
Matthias Krüger 2022-02-19 06:45:29 +01:00 committed by GitHub
commit f19adc7acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 5 additions and 78 deletions

View File

@ -70,6 +70,8 @@ declare_features! (
(accepted, cfg_attr_multi, "1.33.0", Some(54881), None),
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
(accepted, cfg_doctest, "1.40.0", Some(62210), None),
/// Enables `#[cfg(panic = "...")]` config key.
(accepted, cfg_panic, "1.60.0", Some(77443), None),
/// Allows `cfg(target_feature = "...")`.
(accepted, cfg_target_feature, "1.27.0", Some(29717), None),
/// Allows `cfg(target_vendor = "...")`.

View File

@ -306,8 +306,6 @@ declare_features! (
(active, c_variadic, "1.34.0", Some(44930), None),
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
(incomplete, capture_disjoint_fields, "1.49.0", Some(53488), None),
/// Enables `#[cfg(panic = "...")]` config key.
(active, cfg_panic, "1.49.0", Some(77443), None),
/// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used.
(active, cfg_sanitize, "1.41.0", Some(39699), None),
/// Allows `cfg(target_abi = "...")`.

View File

@ -34,7 +34,6 @@ const GATED_CFGS: &[GatedCfg] = &[
(sym::target_has_atomic_load_store, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
(sym::sanitize, sym::cfg_sanitize, cfg_fn!(cfg_sanitize)),
(sym::version, sym::cfg_version, cfg_fn!(cfg_version)),
(sym::panic, sym::cfg_panic, cfg_fn!(cfg_panic)),
];
/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.

View File

@ -6,7 +6,7 @@
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(cell_update)]
#![feature(cfg_panic)]
#![cfg_attr(bootstrap, feature(cfg_panic))]
#![cfg_attr(bootstrap, feature(cfg_target_has_atomic))]
#![feature(const_assume)]
#![feature(const_black_box)]

View File

@ -1,38 +0,0 @@
# `cfg_panic`
The tracking issue for this feature is: [#77443]
[#77443]: https://github.com/rust-lang/rust/issues/77443
------------------------
The `cfg_panic` feature makes it possible to execute different code
depending on the panic strategy.
Possible values at the moment are `"unwind"` or `"abort"`, although
it is possible that new panic strategies may be added to Rust in the
future.
## Examples
```rust
#![feature(cfg_panic)]
#[cfg(panic = "unwind")]
fn a() {
// ...
}
#[cfg(not(panic = "unwind"))]
fn a() {
// ...
}
fn b() {
if cfg!(panic = "abort") {
// ...
} else {
// ...
}
}
```

View File

@ -1,7 +1,7 @@
// build-pass
// compile-flags: -C panic=abort
// no-prefer-dynamic
#![feature(cfg_panic)]
#[cfg(panic = "unwind")]
pub fn bad() -> i32 { }

View File

@ -4,7 +4,7 @@
// ignore-emscripten no panic_unwind implementation
// ignore-wasm32 no panic_unwind implementation
// ignore-wasm64 no panic_unwind implementation
#![feature(cfg_panic)]
#[cfg(panic = "abort")]
pub fn bad() -> i32 { }

View File

@ -1,11 +0,0 @@
#[cfg(panic = "unwind")]
//~^ ERROR `cfg(panic)` is experimental and subject to change
fn foo() -> bool { true }
#[cfg(not(panic = "unwind"))]
//~^ ERROR `cfg(panic)` is experimental and subject to change
fn foo() -> bool { false }
fn main() {
assert!(foo());
}

View File

@ -1,21 +0,0 @@
error[E0658]: `cfg(panic)` is experimental and subject to change
--> $DIR/feature-gate-cfg-panic.rs:1:7
|
LL | #[cfg(panic = "unwind")]
| ^^^^^^^^^^^^^^^^
|
= note: see issue #77443 <https://github.com/rust-lang/rust/issues/77443> for more information
= help: add `#![feature(cfg_panic)]` to the crate attributes to enable
error[E0658]: `cfg(panic)` is experimental and subject to change
--> $DIR/feature-gate-cfg-panic.rs:4:11
|
LL | #[cfg(not(panic = "unwind"))]
| ^^^^^^^^^^^^^^^^
|
= note: see issue #77443 <https://github.com/rust-lang/rust/issues/77443> for more information
= help: add `#![feature(cfg_panic)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,5 +1,4 @@
// run-pass
#![feature(cfg_panic)]
fn main() {
named_argument_takes_precedence_to_captured();

View File

@ -4,7 +4,6 @@
// entering the catch_unwind.
//
// run-pass
#![feature(cfg_panic)]
use std::panic::catch_unwind;