Skip to content

Commit

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

Successful merges:

 - rust-lang#82500 (Reuse `std::sys::unsupported::pipe` on `hermit`)
 - rust-lang#82759 (Remove unwrap_none/expect_none from compiler/.)
 - rust-lang#82846 (rustdoc: allow list syntax for #[doc(alias)] attributes)
 - rust-lang#82892 (Clarify docs for Read::read's return value)
 - rust-lang#83179 (Extend `proc_macro_back_compat` lint to `actix-web`)
 - rust-lang#83197 (Move some test-only code to test files)
 - rust-lang#83208 (Fix gitattibutes for old git versions)
 - rust-lang#83215 (Deprecate std::os::haiku::raw, which accidentally wasn't deprecated)
 - rust-lang#83230 (Remove unnecessary `forward_inner_docs` hack)
 - rust-lang#83236 (Upgrade memmap to memmap2)
 - rust-lang#83270 (Fix typo/inaccuracy in the documentation of Iterator::skip_while)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 19, 2021
2 parents b97fd3e + 99f411d commit 9f4bc3e
Show file tree
Hide file tree
Showing 45 changed files with 530 additions and 252 deletions.
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
*.fixed linguist-language=Rust
*.mir linguist-language=Rust
src/etc/installer/gfx/* binary
*.woff binary
*.woff2 binary
src/vendor/** -text
Cargo.lock linguist-generated=false

# Older git versions try to fix line endings on images, this prevents it.
# Older git versions try to fix line endings on images and fonts, this prevents it.
*.png binary
*.ico binary
*.woff binary
*.woff2 binary
13 changes: 11 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,15 @@ dependencies = [
"winapi 0.3.9",
]

[[package]]
name = "memmap2"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04e3e85b970d650e2ae6d70592474087051c11c54da7f7b4949725c5735fbcc6"
dependencies = [
"libc",
]

[[package]]
name = "memoffset"
version = "0.5.5"
Expand Down Expand Up @@ -3782,7 +3791,7 @@ dependencies = [
"itertools 0.9.0",
"jobserver",
"libc",
"memmap",
"memmap2",
"pathdiff",
"rustc_apfloat",
"rustc_ast",
Expand Down Expand Up @@ -4116,7 +4125,7 @@ name = "rustc_metadata"
version = "0.0.0"
dependencies = [
"libc",
"memmap",
"memmap2",
"rustc_ast",
"rustc_attr",
"rustc_data_structures",
Expand Down
16 changes: 0 additions & 16 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,6 @@ impl<T> TypedArena<T> {
}
}

/// Clears the arena. Deallocates all but the longest chunk which may be reused.
pub fn clear(&mut self) {
unsafe {
// Clear the last chunk, which is partially filled.
let mut chunks_borrow = self.chunks.borrow_mut();
if let Some(mut last_chunk) = chunks_borrow.last_mut() {
self.clear_last_chunk(&mut last_chunk);
let len = chunks_borrow.len();
// If `T` is ZST, code below has no effect.
for mut chunk in chunks_borrow.drain(..len - 1) {
chunk.destroy(chunk.entries);
}
}
}
}

// Drops the contents of the last chunk. The last chunk is partially empty, unlike all other
// chunks.
fn clear_last_chunk(&self, last_chunk: &mut TypedArenaChunk<T>) {
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_arena/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ struct Point {
z: i32,
}

impl<T> TypedArena<T> {
/// Clears the arena. Deallocates all but the longest chunk which may be reused.
fn clear(&mut self) {
unsafe {
// Clear the last chunk, which is partially filled.
let mut chunks_borrow = self.chunks.borrow_mut();
if let Some(mut last_chunk) = chunks_borrow.last_mut() {
self.clear_last_chunk(&mut last_chunk);
let len = chunks_borrow.len();
// If `T` is ZST, code below has no effect.
for mut chunk in chunks_borrow.drain(..len - 1) {
chunk.destroy(chunk.entries);
}
}
}
}
}

#[test]
pub fn test_unused() {
let arena: TypedArena<Point> = TypedArena::default();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test = false
bitflags = "1.2.1"
cc = "1.0.1"
itertools = "0.9"
memmap = "0.7"
memmap2 = "0.2.1"
tracing = "0.1"
libc = "0.2.50"
jobserver = "0.1.11"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
pub enum SerializedModule<M: ModuleBufferMethods> {
Local(M),
FromRlib(Vec<u8>),
FromUncompressedFile(memmap::Mmap),
FromUncompressedFile(memmap2::Mmap),
}

impl<M: ModuleBufferMethods> SerializedModule<M> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
.unwrap_or_else(|e| panic!("failed to open bitcode file `{}`: {}", bc_path.display(), e));

let mmap = unsafe {
memmap::Mmap::map(&file).unwrap_or_else(|e| {
memmap2::Mmap::map(&file).unwrap_or_else(|e| {
panic!("failed to mmap bitcode file `{}`: {}", bc_path.display(), e)
})
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(assert_matches)]
#![feature(bool_to_option)]
#![feature(option_expect_none)]
#![feature(box_patterns)]
#![feature(drain_filter)]
#![feature(try_blocks)]
Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_data_structures/src/tiny_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
mod tests;

#[derive(Clone)]
pub struct TinyList<T: PartialEq> {
pub struct TinyList<T> {
head: Option<Element<T>>,
}

Expand Down Expand Up @@ -56,20 +56,10 @@ impl<T: PartialEq> TinyList<T> {
}
false
}

#[inline]
pub fn len(&self) -> usize {
let (mut elem, mut count) = (self.head.as_ref(), 0);
while let Some(ref e) = elem {
count += 1;
elem = e.next.as_deref();
}
count
}
}

#[derive(Clone)]
struct Element<T: PartialEq> {
struct Element<T> {
data: T,
next: Option<Box<Element<T>>>,
}
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_data_structures/src/tiny_list/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ use super::*;
extern crate test;
use test::{black_box, Bencher};

impl<T> TinyList<T> {
fn len(&self) -> usize {
let (mut elem, mut count) = (self.head.as_ref(), 0);
while let Some(ref e) = elem {
count += 1;
elem = e.next.as_deref();
}
count
}
}

#[test]
fn test_contains_and_insert() {
fn do_insert(i: u32) -> bool {
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_data_structures/src/transitive_relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::mem;
mod tests;

#[derive(Clone, Debug)]
pub struct TransitiveRelation<T: Eq + Hash> {
pub struct TransitiveRelation<T> {
// List of elements. This is used to map from a T to a usize.
elements: FxIndexSet<T>,

Expand Down Expand Up @@ -49,7 +49,7 @@ struct Edge {
target: Index,
}

impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
impl<T: Eq + Hash> TransitiveRelation<T> {
pub fn is_empty(&self) -> bool {
self.edges.is_empty()
}
Expand Down Expand Up @@ -322,12 +322,6 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
.collect()
}

/// A "best" parent in some sense. See `parents` and
/// `postdom_upper_bound` for more details.
pub fn postdom_parent(&self, a: &T) -> Option<&T> {
self.mutual_immediate_postdominator(self.parents(a))
}

fn with_closure<OP, R>(&self, op: OP) -> R
where
OP: FnOnce(&BitMatrix<usize, usize>) -> R,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use super::*;

impl<T: Eq + Hash> TransitiveRelation<T> {
/// A "best" parent in some sense. See `parents` and
/// `postdom_upper_bound` for more details.
fn postdom_parent(&self, a: &T) -> Option<&T> {
self.mutual_immediate_postdominator(self.parents(a))
}
}

#[test]
fn test_one_step() {
let mut relation = TransitiveRelation::default();
Expand Down
21 changes: 6 additions & 15 deletions compiler/rustc_errors/src/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ struct DiagnosticBuilderInner<'a> {
allow_suggestions: bool,
}

/// This is a helper macro for [`forward!`] that allows automatically adding documentation
/// that uses tokens from [`forward!`]'s input.
macro_rules! forward_inner_docs {
($e:expr => $i:item) => {
#[doc = $e]
$i
};
}

/// In general, the `DiagnosticBuilder` uses deref to allow access to
/// the fields and methods of the embedded `diagnostic` in a
/// transparent way. *However,* many of the methods are intended to
Expand All @@ -54,11 +45,11 @@ macro_rules! forward {
pub fn $n:ident(&self, $($name:ident: $ty:ty),* $(,)?) -> &Self
) => {
$(#[$attrs])*
forward_inner_docs!(concat!("See [`Diagnostic::", stringify!($n), "()`].") =>
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
pub fn $n(&self, $($name: $ty),*) -> &Self {
self.diagnostic.$n($($name),*);
self
});
}
};

// Forward pattern for &mut self -> &mut Self
Expand All @@ -67,11 +58,11 @@ macro_rules! forward {
pub fn $n:ident(&mut self, $($name:ident: $ty:ty),* $(,)?) -> &mut Self
) => {
$(#[$attrs])*
forward_inner_docs!(concat!("See [`Diagnostic::", stringify!($n), "()`].") =>
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
pub fn $n(&mut self, $($name: $ty),*) -> &mut Self {
self.0.diagnostic.$n($($name),*);
self
});
}
};

// Forward pattern for &mut self -> &mut Self, with generic parameters.
Expand All @@ -84,11 +75,11 @@ macro_rules! forward {
) -> &mut Self
) => {
$(#[$attrs])*
forward_inner_docs!(concat!("See [`Diagnostic::", stringify!($n), "()`].") =>
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
pub fn $n<$($generic: $bound),*>(&mut self, $($name: $ty),*) -> &mut Self {
self.0.diagnostic.$n($($name),*);
self
});
}
};
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(crate_visibility_modifier)]
#![feature(backtrace)]
#![feature(extended_key_value_attributes)]
#![feature(nll)]

#[macro_use]
Expand Down
Loading

0 comments on commit 9f4bc3e

Please sign in to comment.