Skip to content

Commit

Permalink
Auto merge of rust-lang#84206 - Dylan-DPC:rollup-knl2jgq, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#82492 (Move `std::sys_common::alloc` to new module `std::sys::common`)
 - rust-lang#84177 (Fix join_paths error display.)
 - rust-lang#84185 (add more pat2021 tests)
 - rust-lang#84191 (Update books)
 - rust-lang#84192 (Fix typos in rustc_codegen_ssa/src/back/write.rs.)
 - rust-lang#84196 (:arrow_up: rust-analyzer)
 - rust-lang#84201 (rustdoc: Note that forbidding anchors in links to primitives is a bug)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 14, 2021
2 parents 16bf626 + f4549d2 commit 9c3b66c
Show file tree
Hide file tree
Showing 21 changed files with 153 additions and 17 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
// only place where we have access to the compiler `Session`.
// - LLVM work can be done on any thread.
// - Codegen can only happen on the main thread.
// - Each thread doing substantial work most be in possession of a `Token`
// - Each thread doing substantial work must be in possession of a `Token`
// from the `Jobserver`.
// - The compiler process always holds one `Token`. Any additional `Tokens`
// have to be requested from the `Jobserver`.
Expand Down Expand Up @@ -1146,7 +1146,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
// if possible. These two goals are at odds with each other: If memory
// consumption were not an issue, we could just let the main thread produce
// LLVM WorkItems at full speed, assuring maximal utilization of
// Tokens/LLVM worker threads. However, since codegen usual is faster
// Tokens/LLVM worker threads. However, since codegen is usually faster
// than LLVM processing, the queue of LLVM WorkItems would fill up and each
// WorkItem potentially holds on to a substantial amount of memory.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(dead_code)]

use crate::alloc::{GlobalAlloc, Layout, System};
use crate::cmp;
use crate::ptr;
Expand Down
13 changes: 13 additions & 0 deletions library/std/src/sys/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This module contains code that is shared between all platforms, mostly utility or fallback code.
// This explicitly does not include code that is shared between only a few platforms,
// such as when reusing an implementation from `unix` or `unsupported`.
// In those cases the desired code should be included directly using the #[path] attribute,
// not moved to this module.
//
// Currently `sys_common` contains a lot of code that should live in this module,
// ideally `sys_common` would only contain platform-independent abstractions on top of `sys`.
// Progress on this is tracked in #84187.

#![allow(dead_code)]

pub mod alloc;
2 changes: 2 additions & 0 deletions library/std/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#![allow(missing_debug_implementations)]

mod common;

cfg_if::cfg_if! {
if #[cfg(target_os = "vxworks")] {
mod vxworks;
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/alloc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::alloc::{GlobalAlloc, Layout, System};
use crate::ptr;
use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN};
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};

#[stable(feature = "alloc_system_type", since = "1.28.0")]
unsafe impl GlobalAlloc for System {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ where

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

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/windows/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ffi::c_void;
use crate::ptr;
use crate::sync::atomic::{AtomicPtr, Ordering};
use crate::sys::c;
use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN};
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};

#[cfg(test)]
mod tests;
Expand Down
9 changes: 5 additions & 4 deletions library/std/src/sys_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
//! rest of `std` is complex, with dependencies going in all
//! directions: `std` depending on `sys_common`, `sys_common`
//! depending on `sys`, and `sys` depending on `sys_common` and `std`.
//! Ideally `sys_common` would be split into two and the dependencies
//! between them all would form a dag, facilitating the extraction of
//! `std::sys` from the standard library.
//! This is because `sys_common` not only contains platform-independent code,
//! but also code that is shared between the different platforms in `sys`.
//! Ideally all that shared code should be moved to `sys::common`,
//! and the dependencies between `std`, `sys_common` and `sys` all would form a dag.
//! Progress on this is tracked in #84187.

#![allow(missing_docs)]
#![allow(missing_debug_implementations)]
Expand Down Expand Up @@ -46,7 +48,6 @@ macro_rules! rtunwrap {
};
}

pub mod alloc;
pub mod at_exit_imp;
pub mod backtrace;
pub mod bytestring;
Expand Down
2 changes: 1 addition & 1 deletion src/doc/nomicon
Submodule nomicon updated 1 files
+177 −0 src/send-and-sync.md
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
4 changes: 4 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,10 @@ fn anchor_failure(cx: &DocContext<'_>, diag_info: DiagnosticInfo<'_>, failure: A
if let Some(sp) = sp {
diag.span_label(sp, "contains invalid anchor");
}
if let AnchorFailure::RustdocAnchorConflict(Res::Primitive(_)) = failure {
diag.note("this restriction may be lifted in a future release");
diag.note("see https://github.com/rust-lang/rust/issues/83083 for more information");
}
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/test/rustdoc-ui/intra-doc/anchors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ note: the lint level is defined here
|
LL | #![deny(rustdoc::broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this restriction may be lifted in a future release
= note: see https://github.com/rust-lang/rust/issues/83083 for more information

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

error: aborting due to 5 previous errors

20 changes: 20 additions & 0 deletions src/test/ui/macros/macro-pat-pattern-followed-by-or-in-2021.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// edition:2021
#![allow(unused_macros)]
macro_rules! foo { ($x:pat | $y:pat) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
macro_rules! qux { ($x:pat, $y:pat) => {} } // should be ok
macro_rules! match_any {
( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { //~ ERROR `$pat:pat` may be followed by `|`, which is not allowed for `pat` fragments
match $expr {
$(
$( $pat => $expr_arm, )+
)+
}
};
}

fn main() {
let result: Result<i64, i32> = Err(42);
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
assert_eq!(int, 42);
}
26 changes: 26 additions & 0 deletions src/test/ui/macros/macro-pat-pattern-followed-by-or-in-2021.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error: `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
--> $DIR/macro-pat-pattern-followed-by-or-in-2021.rs:3:28
|
LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
| ^ not allowed after `pat` fragments
|
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
--> $DIR/macro-pat-pattern-followed-by-or-in-2021.rs:4:32
|
LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} }
| ^ not allowed after `pat` fragments
|
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: `$pat:pat` may be followed by `|`, which is not allowed for `pat` fragments
--> $DIR/macro-pat-pattern-followed-by-or-in-2021.rs:7:36
|
LL | ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
| ^ not allowed after `pat` fragments
|
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: aborting due to 3 previous errors

20 changes: 20 additions & 0 deletions src/test/ui/macros/macro-pat-pattern-followed-by-or.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// run-pass
#![allow(unused_macros)]
macro_rules! foo { ($x:pat | $y:pat) => {} } // should be ok
macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } // should be ok
macro_rules! qux { ($x:pat, $y:pat) => {} } // should be ok
macro_rules! match_any {
( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { // should be ok
match $expr {
$(
$( $pat => $expr_arm, )+
)+
}
};
}

fn main() {
let result: Result<i64, i32> = Err(42);
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
assert_eq!(int, 42);
}
21 changes: 21 additions & 0 deletions src/test/ui/macros/macro-pat2021-pattern-followed-by-or.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#![feature(edition_macro_pats)]
#![allow(unused_macros)]
macro_rules! foo { ($x:pat2021 | $y:pat2021) => {} } //~ ERROR `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok
macro_rules! qux { ($x:pat2015 | $y:pat2021) => {} } // should be ok
macro_rules! ogg { ($x:pat2021 | $y:pat2015) => {} } //~ ERROR `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
macro_rules! match_any {
( $expr:expr , $( $( $pat:pat2021 )|+ => $expr_arm:pat2021 ),+ ) => { //~ ERROR `$pat:pat2021` may be followed by `|`, which is not allowed for `pat2021` fragments
match $expr {
$(
$( $pat => $expr_arm, )+
)+
}
};
}

fn main() {
let result: Result<i64, i32> = Err(42);
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
assert_eq!(int, 42);
}
26 changes: 26 additions & 0 deletions src/test/ui/macros/macro-pat2021-pattern-followed-by-or.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error: `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
--> $DIR/macro-pat2021-pattern-followed-by-or.rs:3:32
|
LL | macro_rules! foo { ($x:pat2021 | $y:pat2021) => {} }
| ^ not allowed after `pat2021` fragments
|
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: `$x:pat2021` is followed by `|`, which is not allowed for `pat2021` fragments
--> $DIR/macro-pat2021-pattern-followed-by-or.rs:6:32
|
LL | macro_rules! ogg { ($x:pat2021 | $y:pat2015) => {} }
| ^ not allowed after `pat2021` fragments
|
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: `$pat:pat2021` may be followed by `|`, which is not allowed for `pat2021` fragments
--> $DIR/macro-pat2021-pattern-followed-by-or.rs:8:40
|
LL | ( $expr:expr , $( $( $pat:pat2021 )|+ => $expr_arm:pat2021 ),+ ) => {
| ^ not allowed after `pat2021` fragments
|
= note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: aborting due to 3 previous errors

2 changes: 1 addition & 1 deletion src/tools/rust-analyzer

0 comments on commit 9c3b66c

Please sign in to comment.