Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #83301

Merged
merged 24 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2cbea9f
Reuse `std::sys::unsupported::pipe` on `hermit`
CDirkx Feb 24, 2021
bbbefa3
Allow doc alias attributes to use both list and value
GuillaumeGomez Mar 6, 2021
2069d3e
Update doc alias ui tests
GuillaumeGomez Mar 6, 2021
1d26e6b
Improve code by removing similar function calls and using loops inste…
GuillaumeGomez Mar 8, 2021
cad3c42
Deprecate std::os::haiku::raw
bstrie Mar 16, 2021
bb7c04a
Remove unnecessary `forward_inner_docs` hack
jyn514 Mar 17, 2021
620ecc0
Move some test-only code to test files
jyn514 Mar 17, 2021
b1de9d4
Fix gitattibutes for old git versions
Mar 16, 2021
cfb4ad4
Remove unwrap_none/expect_none from compiler/.
m-ou-se Mar 4, 2021
390d1ef
Extend `proc_macro_back_compat` lint to `actix-web`
Aaron1011 Mar 16, 2021
458d044
Upgrade memmap to memmap2 in other crates.
cjgillot Mar 17, 2021
99b2054
Fix typo/inaccuracy in the documentation of Iterator::skip_while
steffahn Mar 18, 2021
9dfda62
Clarify docs for Read::read's return value
jix Mar 8, 2021
4abcd40
Rollup merge of #82500 - CDirkx:hermit-pipe, r=joshtriplett
Dylan-DPC Mar 19, 2021
2960971
Rollup merge of #82759 - m-ou-se:remove-unwrap-none, r=petrochenkov
Dylan-DPC Mar 19, 2021
61372e1
Rollup merge of #82846 - GuillaumeGomez:doc-alias-list, r=jyn514
Dylan-DPC Mar 19, 2021
db4a97c
Rollup merge of #82892 - jix:clarify-read-read, r=joshtriplett
Dylan-DPC Mar 19, 2021
75571a5
Rollup merge of #83179 - Aaron1011:actix-web-lint, r=petrochenkov
Dylan-DPC Mar 19, 2021
37b7031
Rollup merge of #83197 - jyn514:cfg-test-dead-code, r=joshtriplett
Dylan-DPC Mar 19, 2021
3591242
Rollup merge of #83208 - jethrogb:jb/gitignore, r=Xanewok
Dylan-DPC Mar 19, 2021
675ae2e
Rollup merge of #83215 - bstrie:dephaikuraw, r=joshtriplett
Dylan-DPC Mar 19, 2021
827ad66
Rollup merge of #83230 - jyn514:remove-macros, r=joshtriplett
Dylan-DPC Mar 19, 2021
23128c4
Rollup merge of #83236 - cjgillot:memmap, r=joshtriplett
Dylan-DPC Mar 19, 2021
99f411d
Rollup merge of #83270 - steffahn:missing_word_in_skip_while_doc, r=j…
Dylan-DPC Mar 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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