Skip to content

Commit 1c05d50

Browse files
committed
Auto merge of #117030 - matthiaskrgr:rollup-vdjfx4q, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #116312 (Initiate the inner usage of `cfg_match` (Compiler)) - #116928 (fix bootstrap paths in triagebot.toml) - #116955 (Updated README with expandable table of content.) - #116981 (update the registers of csky target) - #116992 (Mention the syntax for `use` on `mod foo;` if `foo` doesn't exist) - #117026 (Fix broken link to Ayu theme in the rustdoc book) - #117028 (Remove unnecessary `all` in Box) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8581200 + ddb59dc commit 1c05d50

File tree

27 files changed

+108
-77
lines changed

27 files changed

+108
-77
lines changed

Cargo.lock

-2
Original file line numberDiff line numberDiff line change
@@ -3697,7 +3697,6 @@ version = "0.0.0"
36973697
dependencies = [
36983698
"arrayvec",
36993699
"bitflags 1.3.2",
3700-
"cfg-if",
37013700
"elsa",
37023701
"ena",
37033702
"indexmap 2.0.0",
@@ -4529,7 +4528,6 @@ dependencies = [
45294528
name = "rustc_span"
45304529
version = "0.0.0"
45314530
dependencies = [
4532-
"cfg-if",
45334531
"indexmap 2.0.0",
45344532
"md-5",
45354533
"rustc_arena",

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ standard library, and documentation.
1111
If you wish to _contribute_ to the compiler, you should read
1212
[CONTRIBUTING.md](CONTRIBUTING.md) instead.
1313

14+
<details>
15+
<summary>Table of content</summary>
16+
17+
- [Quick Start](#quick-start)
18+
- [Installing from Source](#installing-from-source)
19+
- [Building Documentation](#building-documentation)
20+
- [Notes](#notes)
21+
- [Getting Help](#getting-help)
22+
- [Contributing](#contributing)
23+
- [License](#license)
24+
- [Trademark](#trademark)
25+
26+
</details>
27+
1428
## Quick Start
1529

1630
Read ["Installation"] from [The Book].

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_expand/messages.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ expand_module_circular =
8686
expand_module_file_not_found =
8787
file not found for module `{$name}`
8888
.help = to create the module `{$name}`, create file "{$default_path}" or "{$secondary_path}"
89+
.note = if there is a `mod {$name}` elsewhere in the crate already, import it with `use crate::...` instead
8990
9091
expand_module_in_block =
9192
cannot declare a non-inline module inside a block unless it has a path attribute

compiler/rustc_expand/src/errors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ pub(crate) struct ModuleInBlockName {
350350
#[derive(Diagnostic)]
351351
#[diag(expand_module_file_not_found, code = "E0583")]
352352
#[help]
353+
#[note]
353354
pub(crate) struct ModuleFileNotFound {
354355
#[primary_span]
355356
pub span: Span,

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;

compiler/rustc_target/src/asm/csky.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def_regs! {
6464
r20: reg = ["r20","t4"],// feature high-register
6565
r21: reg = ["r21","t5"],// feature high-register
6666
r22: reg = ["r22","t6"],// feature high-register
67-
r23: reg = ["r23","t7", "fp"],// feature high-register
68-
r24: reg = ["r24","t8", "sop"],// feature high-register
69-
r25: reg = ["r25","t9","tp", "bsp"],// feature high-register
67+
r23: reg = ["r23","t7"],// feature high-register
68+
r24: reg = ["r24","t8"],// feature high-register
69+
r25: reg = ["r25","t9"],// feature high-register
7070
f0: freg = ["fr0","vr0"],
7171
f1: freg = ["fr1","vr1"],
7272
f2: freg = ["fr2","vr2"],

library/alloc/src/boxed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<T> Box<T> {
207207
/// ```
208208
/// let five = Box::new(5);
209209
/// ```
210-
#[cfg(all(not(no_global_oom_handling)))]
210+
#[cfg(not(no_global_oom_handling))]
211211
#[inline(always)]
212212
#[stable(feature = "rust1", since = "1.0.0")]
213213
#[must_use]

src/doc/rustdoc/src/write-documentation/what-to-include.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ rustdoc --theme awesome.css src/lib.rs
117117

118118
Here is an example of a new theme, [Ayu].
119119

120-
[Ayu]: https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/static/css/themes/ayu.css
120+
[Ayu]: https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/static/css/rustdoc.css#L2384-L2574
121121
[API Guidelines]: https://rust-lang.github.io/api-guidelines/documentation.html#rustdoc-does-not-show-unhelpful-implementation-details-c-hidden
122122
[Documentation tests]: documentation-tests.md
123123
[on this blog]: https://blog.guillaume-gomez.fr/articles/2016-09-16+Generating+doc+with+rustdoc+and+a+custom+theme

tests/run-make/unknown-mod-stdin/unknown-mod.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ error[E0583]: file not found for module `unknown`
55
| ^^^^^^^^^^^^
66
|
77
= help: to create the module `unknown`, create file "unknown.rs" or "unknown/mod.rs"
8+
= note: if there is a `mod unknown` elsewhere in the crate already, import it with `use crate::...` instead
89

910
error: aborting due to previous error
1011

tests/ui/error-codes/E0583.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | mod module_that_doesnt_exist;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: to create the module `module_that_doesnt_exist`, create file "$DIR/module_that_doesnt_exist.rs" or "$DIR/module_that_doesnt_exist/mod.rs"
8+
= note: if there is a `mod module_that_doesnt_exist` elsewhere in the crate already, import it with `use crate::...` instead
89

910
error: aborting due to previous error
1011

tests/ui/invalid-module-declaration/invalid-module-declaration.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | pub mod baz;
55
| ^^^^^^^^^^^^
66
|
77
= help: to create the module `baz`, create file "$DIR/auxiliary/foo/bar/baz.rs" or "$DIR/auxiliary/foo/bar/baz/mod.rs"
8+
= note: if there is a `mod baz` elsewhere in the crate already, import it with `use crate::...` instead
89

910
error: aborting due to previous error
1011

tests/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | mod missing;
55
| ^^^^^^^^^^^^
66
|
77
= help: to create the module `missing`, create file "$DIR/foo/missing.rs" or "$DIR/foo/missing/mod.rs"
8+
= note: if there is a `mod missing` elsewhere in the crate already, import it with `use crate::...` instead
89

910
error: aborting due to previous error
1011

0 commit comments

Comments
 (0)