Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 8 additions & 14 deletions compiler/rustc_attr_parsing/src/attributes/cfg_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,14 @@ pub fn parse_cfg_select(
}
}

if let Some(features) = features
&& features.enabled(sym::cfg_select)
{
let it = branches
.reachable
.iter()
.map(|(entry, _, _)| CfgSelectPredicate::Cfg(entry.clone()))
.chain(branches.wildcard.as_ref().map(|(t, _, _)| CfgSelectPredicate::Wildcard(*t)))
.chain(
branches.unreachable.iter().map(|(entry, _, _)| CfgSelectPredicate::clone(entry)),
);

lint_unreachable(p, it, lint_node_id);
}
let it = branches
.reachable
.iter()
.map(|(entry, _, _)| CfgSelectPredicate::Cfg(entry.clone()))
.chain(branches.wildcard.as_ref().map(|(t, _, _)| CfgSelectPredicate::Wildcard(*t)))
.chain(branches.unreachable.iter().map(|(entry, _, _)| CfgSelectPredicate::clone(entry)));

lint_unreachable(p, it, lint_node_id);

Ok(branches)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ index 1e336bf..35e6f54 100644
@@ -2,4 +2,3 @@
// tidy-alphabetical-start
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
#![cfg_attr(test, feature(cfg_select))]
#![feature(array_ptr_get)]
#![feature(array_try_from_fn)]
diff --git a/coretests/tests/atomic.rs b/coretests/tests/atomic.rs
index b735957..ea728b6 100644
--- a/coretests/tests/atomic.rs
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#![allow(internal_features)]
#![allow(rustc::default_hash_types)]
#![allow(rustc::potential_query_instability)]
#![cfg_attr(bootstrap, feature(cfg_select))]
#![deny(unsafe_op_in_unsafe_fn)]
#![feature(allocator_api)]
#![feature(ascii_char)]
#![feature(ascii_char_variants)]
#![feature(assert_matches)]
#![feature(auto_traits)]
#![feature(cfg_select)]
#![feature(const_default)]
#![feature(const_trait_impl)]
#![feature(core_intrinsics)]
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ declare_features! (
(accepted, cfg_doctest, "1.40.0", Some(62210)),
/// Enables `#[cfg(panic = "...")]` config key.
(accepted, cfg_panic, "1.60.0", Some(77443)),
/// Provides a native way to easily manage multiple conditional flags without having to rewrite each clause multiple times.
(accepted, cfg_select, "CURRENT_RUSTC_VERSION", Some(115585)),
/// Allows `cfg(target_abi = "...")`.
(accepted, cfg_target_abi, "1.78.0", Some(80970)),
/// Allows `cfg(target_feature = "...")`.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ declare_features! (
(unstable, cfg_sanitize, "1.41.0", Some(39699)),
/// Allows `cfg(sanitizer_cfi_generalize_pointers)` and `cfg(sanitizer_cfi_normalize_integers)`.
(unstable, cfg_sanitizer_cfi, "1.77.0", Some(89653)),
/// Provides a native way to easily manage multiple conditional flags without having to rewrite each clause multiple times.
(unstable, cfg_select, "CURRENT_RUSTC_VERSION", Some(115585)),
/// Allows `cfg(target(abi = "..."))`.
(unstable, cfg_target_compact, "1.63.0", Some(96901)),
/// Allows `cfg(target_has_atomic_load_store = "...")`.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,6 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// #![feature(cfg_select)]
/// cfg_select! {
/// _ => (),
/// windows => (),
Expand All @@ -881,7 +880,6 @@ declare_lint! {
pub UNREACHABLE_CFG_SELECT_PREDICATES,
Warn,
"detects unreachable configuration predicates in the cfg_select macro",
@feature_gate = cfg_select;
}

declare_lint! {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

// tidy-alphabetical-start
#![allow(internal_features)]
#![cfg_attr(bootstrap, feature(cfg_select))]
#![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))]
#![feature(cfg_select)]
#![feature(core_io_borrowed_buf)]
#![feature(if_let_guard)]
#![feature(map_try_insert)]
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
#![feature(asm_experimental_arch)]
#![feature(bstr)]
#![feature(bstr_internals)]
#![feature(cfg_select)]
#![feature(cfg_target_has_reliable_f16_f128)]
#![feature(const_carrying_mul_add)]
#![feature(const_cmp)]
Expand Down Expand Up @@ -246,7 +245,7 @@ pub mod autodiff {
#[unstable(feature = "contracts", issue = "128044")]
pub mod contracts;

#[unstable(feature = "cfg_select", issue = "115585")]
#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
pub use crate::macros::cfg_select;

#[macro_use]
Expand Down
6 changes: 1 addition & 5 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ pub macro assert_matches {
/// # Example
///
/// ```
/// #![feature(cfg_select)]
///
/// cfg_select! {
/// unix => {
/// fn foo() { /* unix specific functionality */ }
Expand All @@ -227,14 +225,12 @@ pub macro assert_matches {
/// right-hand side:
///
/// ```
/// #![feature(cfg_select)]
///
/// let _some_string = cfg_select! {
/// unix => "With great power comes great electricity bills",
/// _ => { "Behind every successful diet is an unwatched pizza" }
/// };
/// ```
#[unstable(feature = "cfg_select", issue = "115585")]
#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
#[rustc_diagnostic_item = "cfg_select"]
#[rustc_builtin_macro]
pub macro cfg_select($($tt:tt)*) {
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod ambiguous_macros_only {
#[doc(no_inline)]
pub use self::ambiguous_macros_only::{env, panic};

#[unstable(feature = "cfg_select", issue = "115585")]
#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
#[doc(no_inline)]
pub use crate::cfg_select;

Expand Down
1 change: 0 additions & 1 deletion library/coretests/tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// tidy-alphabetical-start
#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
#![cfg_attr(test, feature(cfg_select))]
#![feature(array_ptr_get)]
#![feature(array_try_from_fn)]
#![feature(array_try_map)]
Expand Down
1 change: 0 additions & 1 deletion library/panic_unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#![unstable(feature = "panic_unwind", issue = "32837")]
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![feature(cfg_emscripten_wasm_eh)]
#![feature(cfg_select)]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(panic_unwind)]
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@
#![feature(bstr)]
#![feature(bstr_internals)]
#![feature(cast_maybe_uninit)]
#![feature(cfg_select)]
#![feature(char_internals)]
#![feature(clone_to_uninit)]
#![feature(const_convert)]
Expand Down Expand Up @@ -696,7 +695,7 @@ mod panicking;
#[allow(dead_code, unused_attributes, fuzzy_provenance_casts, unsafe_op_in_unsafe_fn)]
mod backtrace_rs;

#[unstable(feature = "cfg_select", issue = "115585")]
#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
pub use core::cfg_select;
#[unstable(
feature = "concat_bytes",
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod ambiguous_macros_only {
#[doc(no_inline)]
pub use self::ambiguous_macros_only::{vec, panic};

#[unstable(feature = "cfg_select", issue = "115585")]
#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
#[doc(no_inline)]
pub use core::prelude::v1::cfg_select;

Expand Down
1 change: 0 additions & 1 deletion library/std/tests/env_modify.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// These tests are in a separate integration test as they modify the environment,
// and would otherwise cause some other tests to fail.
#![feature(cfg_select)]

use std::env::*;
use std::ffi::{OsStr, OsString};
Expand Down
2 changes: 1 addition & 1 deletion library/std_detect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! * `s390x`: [`is_s390x_feature_detected`]

#![unstable(feature = "stdarch_internal", issue = "none")]
#![feature(staged_api, cfg_select, doc_cfg, allow_internal_unstable)]
#![feature(staged_api, doc_cfg, allow_internal_unstable)]
#![deny(rust_2018_idioms)]
#![allow(clippy::shadow_reuse)]
#![cfg_attr(test, allow(unused_imports))]
Expand Down
1 change: 0 additions & 1 deletion library/unwind/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_std]
#![unstable(feature = "panic_unwind", issue = "32837")]
#![feature(cfg_emscripten_wasm_eh)]
#![feature(cfg_select)]
#![feature(link_cfg)]
#![feature(staged_api)]
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(abort_unwind)]
#![feature(cfg_select)]
#![feature(rustc_private)]
#![feature(float_gamma)]
#![feature(float_erf)]
Expand All @@ -17,6 +16,7 @@
#![feature(derive_coerce_pointee)]
#![feature(arbitrary_self_types)]
#![feature(iter_advance_by)]
#![cfg_attr(bootstrap, feature(cfg_select))]
// Configure clippy and other lints
#![allow(
clippy::collapsible_else_if,
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/float_extra_rounding_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//@revisions: random max none
//@[max]compile-flags: -Zmiri-max-extra-rounding-error
//@[none]compile-flags: -Zmiri-no-extra-rounding-error
#![feature(cfg_select)]

use std::collections::HashSet;
use std::hint::black_box;
Expand Down
1 change: 0 additions & 1 deletion tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![crate_type = "staticlib"]
#![feature(c_variadic)]
#![feature(cfg_select)]

use std::ffi::{CStr, CString, VaList, c_char, c_double, c_int, c_long, c_longlong};

Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//@ revisions: reva revb
//@ only-x86_64
//@ run-pass
#![feature(cfg_select)]

use std::arch::{asm, naked_asm};

Expand Down
1 change: 0 additions & 1 deletion tests/ui/check-cfg/cfg-select.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ check-pass

#![feature(cfg_select)]
#![crate_type = "lib"]

cfg_select! {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/check-cfg/cfg-select.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `invalid_cfg1`
--> $DIR/cfg-select.rs:8:5
--> $DIR/cfg-select.rs:7:5
|
LL | invalid_cfg1 => {}
| ^^^^^^^^^^^^
Expand All @@ -10,7 +10,7 @@ LL | invalid_cfg1 => {}
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition name: `invalid_cfg2`
--> $DIR/cfg-select.rs:14:5
--> $DIR/cfg-select.rs:13:5
|
LL | invalid_cfg2 => {}
| ^^^^^^^^^^^^
Expand Down
11 changes: 0 additions & 11 deletions tests/ui/feature-gates/feature-gate-cfg-select.rs

This file was deleted.

25 changes: 0 additions & 25 deletions tests/ui/feature-gates/feature-gate-cfg-select.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui/macros/cfg_select.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(cfg_select)]
#![crate_type = "lib"]
#![warn(unreachable_cfg_select_predicates)] // Unused warnings are disabled by default in UI tests.

Expand Down
Loading
Loading