Skip to content

Commit 6788aa3

Browse files
committed
Initiate the inner usage of cfg_match (Compiler)
1 parent e76cb8c commit 6788aa3

File tree

11 files changed

+67
-65
lines changed

11 files changed

+67
-65
lines changed

Cargo.lock

-2
Original file line numberDiff line numberDiff line change
@@ -3664,7 +3664,6 @@ version = "0.0.0"
36643664
dependencies = [
36653665
"arrayvec",
36663666
"bitflags 1.3.2",
3667-
"cfg-if",
36683667
"elsa",
36693668
"ena",
36703669
"indexmap 2.0.0",
@@ -4496,7 +4495,6 @@ dependencies = [
44964495
name = "rustc_span"
44974496
version = "0.0.0"
44984497
dependencies = [
4499-
"cfg-if",
45004498
"indexmap 2.0.0",
45014499
"md-5",
45024500
"rustc_arena",

compiler/rustc_data_structures/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2021"
88
[dependencies]
99
arrayvec = { version = "0.7", default-features = false }
1010
bitflags = "1.2.1"
11-
cfg-if = "1.0"
1211
ena = "0.14.2"
1312
indexmap = { version = "2.0.0" }
1413
jobserver_crate = { version = "0.1.13", package = "jobserver" }

compiler/rustc_data_structures/src/flock.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
//! green/native threading. This is just a bare-bones enough solution for
55
//! librustdoc, it is not production quality at all.
66
7-
cfg_if! {
8-
if #[cfg(target_os = "linux")] {
7+
cfg_match! {
8+
cfg(target_os = "linux") => {
99
mod linux;
1010
use linux as imp;
11-
} else if #[cfg(unix)] {
11+
}
12+
cfg(unix) => {
1213
mod unix;
1314
use unix as imp;
14-
} else if #[cfg(windows)] {
15+
}
16+
cfg(windows) => {
1517
mod windows;
1618
use self::windows as imp;
17-
} else {
19+
}
20+
_ => {
1821
mod unsupported;
1922
use unsupported as imp;
2023
}

compiler/rustc_data_structures/src/lib.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,44 @@
66
//!
77
//! This API is completely unstable and subject to change.
88
9+
// tidy-alphabetical-start
10+
#![allow(internal_features)]
11+
#![allow(rustc::default_hash_types)]
12+
#![allow(rustc::potential_query_instability)]
913
#![cfg_attr(not(bootstrap), doc(rust_logo))]
1014
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
15+
#![deny(rustc::diagnostic_outside_of_impl)]
16+
#![deny(rustc::untranslatable_diagnostic)]
17+
#![deny(unsafe_op_in_unsafe_fn)]
1118
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
19+
#![feature(allocator_api)]
1220
#![feature(array_windows)]
1321
#![feature(auto_traits)]
1422
#![feature(cell_leak)]
23+
#![feature(cfg_match)]
1524
#![feature(core_intrinsics)]
1625
#![feature(extend_one)]
1726
#![feature(hash_raw_entry)]
1827
#![feature(hasher_prefixfree_extras)]
28+
#![feature(lazy_cell)]
29+
#![feature(lint_reasons)]
30+
#![feature(macro_metavar_expr)]
1931
#![feature(maybe_uninit_uninit_array)]
2032
#![feature(min_specialization)]
33+
#![feature(negative_impls)]
2134
#![feature(never_type)]
22-
#![feature(type_alias_impl_trait)]
23-
#![feature(lazy_cell)]
35+
#![feature(ptr_alignment_type)]
2436
#![feature(rustc_attrs)]
25-
#![feature(negative_impls)]
37+
#![feature(strict_provenance)]
2638
#![feature(test)]
2739
#![feature(thread_id_value)]
28-
#![feature(allocator_api)]
29-
#![feature(lint_reasons)]
40+
#![feature(type_alias_impl_trait)]
3041
#![feature(unwrap_infallible)]
31-
#![feature(strict_provenance)]
32-
#![feature(ptr_alignment_type)]
33-
#![feature(macro_metavar_expr)]
34-
#![allow(rustc::default_hash_types)]
35-
#![allow(rustc::potential_query_instability)]
36-
#![deny(rustc::untranslatable_diagnostic)]
37-
#![deny(rustc::diagnostic_outside_of_impl)]
38-
#![allow(internal_features)]
39-
#![deny(unsafe_op_in_unsafe_fn)]
42+
// tidy-alphabetical-end
4043

4144
#[macro_use]
4245
extern crate tracing;
4346
#[macro_use]
44-
extern crate cfg_if;
45-
#[macro_use]
4647
extern crate rustc_macros;
4748

4849
use std::fmt;

compiler/rustc_data_structures/src/marker.rs

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
cfg_if!(
2-
if #[cfg(not(parallel_compiler))] {
1+
cfg_match! {
2+
cfg(not(parallel_compiler)) => {
33
pub auto trait DynSend {}
44
pub auto trait DynSync {}
55

66
impl<T> DynSend for T {}
77
impl<T> DynSync for T {}
8-
} else {
8+
}
9+
_ => {
910
#[rustc_on_unimplemented(
1011
message = "`{Self}` doesn't implement `DynSend`. \
1112
Add it to `rustc_data_structures::marker` or use `IntoDynSyncSend` if it's already `Send`"
@@ -48,13 +49,10 @@ cfg_if!(
4849
[std::io::StdoutLock<'_>]
4950
[std::io::StderrLock<'_>]
5051
);
51-
cfg_if!(
52-
// Consistent with `std`
53-
// `os_imp::Env` is `!Send` in these platforms
54-
if #[cfg(any(unix, target_os = "hermit", target_os = "wasi", target_os = "solid_asp3"))] {
55-
impl !DynSend for std::env::VarsOs {}
56-
}
57-
);
52+
53+
#[cfg(any(unix, target_os = "hermit", target_os = "wasi", target_os = "solid_asp3"))]
54+
// Consistent with `std`, `os_imp::Env` is `!Sync` in these platforms
55+
impl !DynSend for std::env::VarsOs {}
5856

5957
macro_rules! already_send {
6058
($([$ty: ty])*) => {
@@ -123,13 +121,10 @@ cfg_if!(
123121
[std::sync::mpsc::Receiver<T> where T]
124122
[std::sync::mpsc::Sender<T> where T]
125123
);
126-
cfg_if!(
127-
// Consistent with `std`
128-
// `os_imp::Env` is `!Sync` in these platforms
129-
if #[cfg(any(unix, target_os = "hermit", target_os = "wasi", target_os = "solid_asp3"))] {
130-
impl !DynSync for std::env::VarsOs {}
131-
}
132-
);
124+
125+
#[cfg(any(unix, target_os = "hermit", target_os = "wasi", target_os = "solid_asp3"))]
126+
// Consistent with `std`, `os_imp::Env` is `!Sync` in these platforms
127+
impl !DynSync for std::env::VarsOs {}
133128

134129
macro_rules! already_sync {
135130
($([$ty: ty])*) => {
@@ -183,7 +178,7 @@ cfg_if!(
183178
[thin_vec::ThinVec<T> where T: DynSync]
184179
);
185180
}
186-
);
181+
}
187182

188183
pub fn assert_dyn_sync<T: ?Sized + DynSync>() {}
189184
pub fn assert_dyn_send<T: ?Sized + DynSend>() {}

compiler/rustc_data_structures/src/profiling.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,8 @@ fn get_thread_id() -> u32 {
859859
}
860860

861861
// Memory reporting
862-
cfg_if! {
863-
if #[cfg(windows)] {
862+
cfg_match! {
863+
cfg(windows) => {
864864
pub fn get_resident_set_size() -> Option<usize> {
865865
use std::mem;
866866

@@ -885,7 +885,8 @@ cfg_if! {
885885

886886
Some(pmc.WorkingSetSize)
887887
}
888-
} else if #[cfg(target_os = "macos")] {
888+
}
889+
cfg(target_os = "macos") => {
889890
pub fn get_resident_set_size() -> Option<usize> {
890891
use libc::{c_int, c_void, getpid, proc_pidinfo, proc_taskinfo, PROC_PIDTASKINFO};
891892
use std::mem;
@@ -903,7 +904,8 @@ cfg_if! {
903904
}
904905
}
905906
}
906-
} else if #[cfg(unix)] {
907+
}
908+
cfg(unix) => {
907909
pub fn get_resident_set_size() -> Option<usize> {
908910
let field = 1;
909911
let contents = fs::read("/proc/self/statm").ok()?;
@@ -912,7 +914,8 @@ cfg_if! {
912914
let npages = s.parse::<usize>().ok()?;
913915
Some(npages * 4096)
914916
}
915-
} else {
917+
}
918+
_ => {
916919
pub fn get_resident_set_size() -> Option<usize> {
917920
None
918921
}

compiler/rustc_data_structures/src/sync.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ mod mode {
109109

110110
pub use mode::{is_dyn_thread_safe, set_dyn_thread_safe_mode};
111111

112-
cfg_if! {
113-
if #[cfg(not(parallel_compiler))] {
112+
cfg_match! {
113+
cfg(not(parallel_compiler)) => {
114114
use std::ops::Add;
115115
use std::cell::Cell;
116116

@@ -251,7 +251,8 @@ cfg_if! {
251251
MTLock(self.0.clone())
252252
}
253253
}
254-
} else {
254+
}
255+
_ => {
255256
pub use std::marker::Send as Send;
256257
pub use std::marker::Sync as Sync;
257258

compiler/rustc_span/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ rustc_index = { path = "../rustc_index" }
1313
rustc_arena = { path = "../rustc_arena" }
1414
scoped-tls = "1.0"
1515
unicode-width = "0.1.4"
16-
cfg-if = "1.0"
1716
tracing = "0.1"
1817
sha1 = "0.10.0"
1918
sha2 = "0.10.1"

compiler/rustc_span/src/analyze_source_file.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub fn analyze_source_file(
3333
(lines, multi_byte_chars, non_narrow_chars)
3434
}
3535

36-
cfg_if::cfg_if! {
37-
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
36+
cfg_match! {
37+
cfg(any(target_arch = "x86", target_arch = "x86_64")) => {
3838
fn analyze_source_file_dispatch(src: &str,
3939
lines: &mut Vec<RelativeBytePos>,
4040
multi_byte_chars: &mut Vec<MultiByteChar>,
@@ -172,8 +172,8 @@ cfg_if::cfg_if! {
172172
non_narrow_chars);
173173
}
174174
}
175-
} else {
176-
175+
}
176+
_ => {
177177
// The target (or compiler version) does not support SSE2 ...
178178
fn analyze_source_file_dispatch(src: &str,
179179
lines: &mut Vec<RelativeBytePos>,

compiler/rustc_span/src/lib.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@
1313
//!
1414
//! This API is completely unstable and subject to change.
1515
16-
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
16+
// tidy-alphabetical-start
17+
#![allow(internal_features)]
1718
#![cfg_attr(not(bootstrap), doc(rust_logo))]
1819
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
20+
#![deny(rustc::diagnostic_outside_of_impl)]
21+
#![deny(rustc::untranslatable_diagnostic)]
22+
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1923
#![feature(array_windows)]
24+
#![feature(cfg_match)]
2025
#![feature(if_let_guard)]
21-
#![feature(negative_impls)]
22-
#![feature(min_specialization)]
23-
#![feature(rustc_attrs)]
2426
#![feature(let_chains)]
25-
#![feature(round_char_boundary)]
26-
#![feature(read_buf)]
27+
#![feature(min_specialization)]
28+
#![feature(negative_impls)]
2729
#![feature(new_uninit)]
28-
#![deny(rustc::untranslatable_diagnostic)]
29-
#![deny(rustc::diagnostic_outside_of_impl)]
30-
#![allow(internal_features)]
30+
#![feature(read_buf)]
31+
#![feature(round_char_boundary)]
32+
#![feature(rustc_attrs)]
33+
// tidy-alphabetical-end
3134

3235
#[macro_use]
3336
extern crate rustc_macros;

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
1111
const ENTRY_LIMIT: usize = 900;
1212
// FIXME: The following limits should be reduced eventually.
1313
const ISSUES_ENTRY_LIMIT: usize = 1854;
14-
const ROOT_ENTRY_LIMIT: usize = 865;
14+
const ROOT_ENTRY_LIMIT: usize = 866;
1515

1616
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
1717
"rs", // test source files

0 commit comments

Comments
 (0)