Skip to content

Commit 9c3b66c

Browse files
committed
Auto merge of #84206 - Dylan-DPC:rollup-knl2jgq, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #82492 (Move `std::sys_common::alloc` to new module `std::sys::common`) - #84177 (Fix join_paths error display.) - #84185 (add more pat2021 tests) - #84191 (Update books) - #84192 (Fix typos in rustc_codegen_ssa/src/back/write.rs.) - #84196 (:arrow_up: rust-analyzer) - #84201 (rustdoc: Note that forbidding anchors in links to primitives is a bug) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 16bf626 + f4549d2 commit 9c3b66c

21 files changed

+153
-17
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
10941094
// only place where we have access to the compiler `Session`.
10951095
// - LLVM work can be done on any thread.
10961096
// - Codegen can only happen on the main thread.
1097-
// - Each thread doing substantial work most be in possession of a `Token`
1097+
// - Each thread doing substantial work must be in possession of a `Token`
10981098
// from the `Jobserver`.
10991099
// - The compiler process always holds one `Token`. Any additional `Tokens`
11001100
// have to be requested from the `Jobserver`.
@@ -1146,7 +1146,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
11461146
// if possible. These two goals are at odds with each other: If memory
11471147
// consumption were not an issue, we could just let the main thread produce
11481148
// LLVM WorkItems at full speed, assuring maximal utilization of
1149-
// Tokens/LLVM worker threads. However, since codegen usual is faster
1149+
// Tokens/LLVM worker threads. However, since codegen is usually faster
11501150
// than LLVM processing, the queue of LLVM WorkItems would fill up and each
11511151
// WorkItem potentially holds on to a substantial amount of memory.
11521152
//

library/std/src/sys_common/alloc.rs renamed to library/std/src/sys/common/alloc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use crate::alloc::{GlobalAlloc, Layout, System};
42
use crate::cmp;
53
use crate::ptr;

library/std/src/sys/common/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This module contains code that is shared between all platforms, mostly utility or fallback code.
2+
// This explicitly does not include code that is shared between only a few platforms,
3+
// such as when reusing an implementation from `unix` or `unsupported`.
4+
// In those cases the desired code should be included directly using the #[path] attribute,
5+
// not moved to this module.
6+
//
7+
// Currently `sys_common` contains a lot of code that should live in this module,
8+
// ideally `sys_common` would only contain platform-independent abstractions on top of `sys`.
9+
// Progress on this is tracked in #84187.
10+
11+
#![allow(dead_code)]
12+
13+
pub mod alloc;

library/std/src/sys/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
2323
#![allow(missing_debug_implementations)]
2424

25+
mod common;
26+
2527
cfg_if::cfg_if! {
2628
if #[cfg(target_os = "vxworks")] {
2729
mod vxworks;

library/std/src/sys/unix/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::alloc::{GlobalAlloc, Layout, System};
22
use crate::ptr;
3-
use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN};
3+
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
44

55
#[stable(feature = "alloc_system_type", since = "1.28.0")]
66
unsafe impl GlobalAlloc for System {

library/std/src/sys/unix/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ where
223223

224224
impl fmt::Display for JoinPathsError {
225225
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
226-
write!(f, "path segment contains separator `{}`", PATH_SEPARATOR)
226+
write!(f, "path segment contains separator `{}`", char::from(PATH_SEPARATOR))
227227
}
228228
}
229229

library/std/src/sys/windows/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ffi::c_void;
55
use crate::ptr;
66
use crate::sync::atomic::{AtomicPtr, Ordering};
77
use crate::sys::c;
8-
use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN};
8+
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
99

1010
#[cfg(test)]
1111
mod tests;

library/std/src/sys_common/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
//! rest of `std` is complex, with dependencies going in all
99
//! directions: `std` depending on `sys_common`, `sys_common`
1010
//! depending on `sys`, and `sys` depending on `sys_common` and `std`.
11-
//! Ideally `sys_common` would be split into two and the dependencies
12-
//! between them all would form a dag, facilitating the extraction of
13-
//! `std::sys` from the standard library.
11+
//! This is because `sys_common` not only contains platform-independent code,
12+
//! but also code that is shared between the different platforms in `sys`.
13+
//! Ideally all that shared code should be moved to `sys::common`,
14+
//! and the dependencies between `std`, `sys_common` and `sys` all would form a dag.
15+
//! Progress on this is tracked in #84187.
1416
1517
#![allow(missing_docs)]
1618
#![allow(missing_debug_implementations)]
@@ -46,7 +48,6 @@ macro_rules! rtunwrap {
4648
};
4749
}
4850

49-
pub mod alloc;
5051
pub mod at_exit_imp;
5152
pub mod backtrace;
5253
pub mod bytestring;

src/doc/nomicon

src/librustdoc/passes/collect_intra_doc_links.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,10 @@ fn anchor_failure(cx: &DocContext<'_>, diag_info: DiagnosticInfo<'_>, failure: A
19721972
if let Some(sp) = sp {
19731973
diag.span_label(sp, "contains invalid anchor");
19741974
}
1975+
if let AnchorFailure::RustdocAnchorConflict(Res::Primitive(_)) = failure {
1976+
diag.note("this restriction may be lifted in a future release");
1977+
diag.note("see https://github.com/rust-lang/rust/issues/83083 for more information");
1978+
}
19751979
});
19761980
}
19771981

src/test/rustdoc-ui/intra-doc/anchors.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(rustdoc::broken_intra_doc_links)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= note: this restriction may be lifted in a future release
13+
= note: see https://github.com/rust-lang/rust/issues/83083 for more information
1214

1315
error: `Foo::f#hola` contains an anchor, but links to fields are already anchored
1416
--> $DIR/anchors.rs:25:15
@@ -33,6 +35,9 @@ error: `u32#hello` contains an anchor, but links to builtin types are already an
3335
|
3436
LL | /// [u32#hello]
3537
| ^^^^^^^^^ contains invalid anchor
38+
|
39+
= note: this restriction may be lifted in a future release
40+
= note: see https://github.com/rust-lang/rust/issues/83083 for more information
3641

3742
error: aborting due to 5 previous errors
3843

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// edition:2021
2+
#![allow(unused_macros)]
3+
macro_rules! foo { ($x:pat | $y:pat) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
4+
macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
5+
macro_rules! qux { ($x:pat, $y:pat) => {} } // should be ok
6+
macro_rules! match_any {
7+
( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { //~ ERROR `$pat:pat` may be followed by `|`, which is not allowed for `pat` fragments
8+
match $expr {
9+
$(
10+
$( $pat => $expr_arm, )+
11+
)+
12+
}
13+
};
14+
}
15+
16+
fn main() {
17+
let result: Result<i64, i32> = Err(42);
18+
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
19+
assert_eq!(int, 42);
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error: `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
2+
--> $DIR/macro-pat-pattern-followed-by-or-in-2021.rs:3:28
3+
|
4+
LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
5+
| ^ not allowed after `pat` fragments
6+
|
7+
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`
8+
9+
error: `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
10+
--> $DIR/macro-pat-pattern-followed-by-or-in-2021.rs:4:32
11+
|
12+
LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} }
13+
| ^ not allowed after `pat` fragments
14+
|
15+
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`
16+
17+
error: `$pat:pat` may be followed by `|`, which is not allowed for `pat` fragments
18+
--> $DIR/macro-pat-pattern-followed-by-or-in-2021.rs:7:36
19+
|
20+
LL | ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
21+
| ^ not allowed after `pat` fragments
22+
|
23+
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`
24+
25+
error: aborting due to 3 previous errors
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// run-pass
2+
#![allow(unused_macros)]
3+
macro_rules! foo { ($x:pat | $y:pat) => {} } // should be ok
4+
macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } // should be ok
5+
macro_rules! qux { ($x:pat, $y:pat) => {} } // should be ok
6+
macro_rules! match_any {
7+
( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { // should be ok
8+
match $expr {
9+
$(
10+
$( $pat => $expr_arm, )+
11+
)+
12+
}
13+
};
14+
}
15+
16+
fn main() {
17+
let result: Result<i64, i32> = Err(42);
18+
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
19+
assert_eq!(int, 42);
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(edition_macro_pats)]
2+
#![allow(unused_macros)]
3+
macro_rules! foo { ($x:pat2021 | $y:pat2021) => {} } //~ ERROR `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
4+
macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok
5+
macro_rules! qux { ($x:pat2015 | $y:pat2021) => {} } // should be ok
6+
macro_rules! ogg { ($x:pat2021 | $y:pat2015) => {} } //~ ERROR `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
7+
macro_rules! match_any {
8+
( $expr:expr , $( $( $pat:pat2021 )|+ => $expr_arm:pat2021 ),+ ) => { //~ ERROR `$pat:pat2021` may be followed by `|`, which is not allowed for `pat2021` fragments
9+
match $expr {
10+
$(
11+
$( $pat => $expr_arm, )+
12+
)+
13+
}
14+
};
15+
}
16+
17+
fn main() {
18+
let result: Result<i64, i32> = Err(42);
19+
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
20+
assert_eq!(int, 42);
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error: `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
2+
--> $DIR/macro-pat2021-pattern-followed-by-or.rs:3:32
3+
|
4+
LL | macro_rules! foo { ($x:pat2021 | $y:pat2021) => {} }
5+
| ^ not allowed after `pat2021` fragments
6+
|
7+
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`
8+
9+
error: `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
10+
--> $DIR/macro-pat2021-pattern-followed-by-or.rs:6:32
11+
|
12+
LL | macro_rules! ogg { ($x:pat2021 | $y:pat2015) => {} }
13+
| ^ not allowed after `pat2021` fragments
14+
|
15+
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`
16+
17+
error: `$pat:pat2021` may be followed by `|`, which is not allowed for `pat2021` fragments
18+
--> $DIR/macro-pat2021-pattern-followed-by-or.rs:8:40
19+
|
20+
LL | ( $expr:expr , $( $( $pat:pat2021 )|+ => $expr_arm:pat2021 ),+ ) => {
21+
| ^ not allowed after `pat2021` fragments
22+
|
23+
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`
24+
25+
error: aborting due to 3 previous errors
26+

src/tools/rust-analyzer

0 commit comments

Comments
 (0)