Skip to content

Commit

Permalink
Auto merge of #68360 - Dylan-DPC:rollup-iej35pz, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #67682 ([const-prop] Remove useless typedef)
 - #68133 (Slimmer syntax)
 - #68154 (Add more BTreeMap/BTreeSet benchmarks regarding iteration)
 - #68247 (Clean up err codes)
 - #68348 (Make iter::Empty<T> Send and Sync for any T)

Failed merges:

 - #68353 (Remove `rustc_error_codes` deps except in `rustc_driver`)

r? @ghost
  • Loading branch information
bors committed Jan 19, 2020
2 parents 6250d56 + cfc0f54 commit 29f163e
Show file tree
Hide file tree
Showing 146 changed files with 547 additions and 388 deletions.
61 changes: 56 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3091,6 +3091,7 @@ dependencies = [
"rustc-rayon",
"rustc-rayon-core",
"rustc_apfloat",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand Down Expand Up @@ -3357,6 +3358,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3374,6 +3376,8 @@ name = "rustc_ast_passes"
version = "0.0.0"
dependencies = [
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3384,12 +3388,41 @@ dependencies = [
"syntax",
]

[[package]]
name = "rustc_ast_pretty"
version = "0.0.0"
dependencies = [
"log",
"rustc_data_structures",
"rustc_span",
"syntax",
]

[[package]]
name = "rustc_attr"
version = "0.0.0"
dependencies = [
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
"rustc_feature",
"rustc_macros",
"rustc_session",
"rustc_span",
"serialize",
"smallvec 1.0.0",
"syntax",
]

[[package]]
name = "rustc_builtin_macros"
version = "0.0.0"
dependencies = [
"fmt_macros",
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3413,6 +3446,7 @@ dependencies = [
"log",
"rustc",
"rustc-demangle",
"rustc_attr",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
Expand Down Expand Up @@ -3443,6 +3477,7 @@ dependencies = [
"num_cpus",
"rustc",
"rustc_apfloat",
"rustc_attr",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_error_codes",
Expand Down Expand Up @@ -3508,6 +3543,7 @@ dependencies = [
"lazy_static 1.3.0",
"log",
"rustc",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_error_codes",
Expand Down Expand Up @@ -3554,6 +3590,8 @@ version = "0.0.0"
dependencies = [
"log",
"rustc_ast_passes",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
Expand Down Expand Up @@ -3583,11 +3621,11 @@ version = "0.0.0"
name = "rustc_hir"
version = "0.0.0"
dependencies = [
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_macros",
"rustc_session",
"rustc_span",
"rustc_target",
"serialize",
Expand Down Expand Up @@ -3630,6 +3668,7 @@ dependencies = [
"rustc-rayon",
"rustc_ast_lowering",
"rustc_ast_passes",
"rustc_attr",
"rustc_builtin_macros",
"rustc_codegen_llvm",
"rustc_codegen_ssa",
Expand Down Expand Up @@ -3674,6 +3713,8 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand Down Expand Up @@ -3715,6 +3756,8 @@ dependencies = [
"log",
"memmap",
"rustc",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand Down Expand Up @@ -3743,6 +3786,8 @@ dependencies = [
"polonius-engine",
"rustc",
"rustc_apfloat",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3766,6 +3811,7 @@ dependencies = [
"log",
"rustc",
"rustc_apfloat",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3785,6 +3831,8 @@ version = "0.0.0"
dependencies = [
"bitflags",
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3803,6 +3851,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand Down Expand Up @@ -3835,6 +3884,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3853,6 +3903,8 @@ dependencies = [
"log",
"rustc",
"rustc_ast_lowering",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand All @@ -3874,6 +3926,7 @@ dependencies = [
"rls-data",
"rls-span",
"rustc",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_hir",
Expand All @@ -3898,6 +3951,7 @@ dependencies = [
"rustc_span",
"rustc_target",
"serialize",
"syntax",
]

[[package]]
Expand Down Expand Up @@ -3972,6 +4026,7 @@ dependencies = [
"arena",
"log",
"rustc",
"rustc_attr",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand Down Expand Up @@ -4493,13 +4548,9 @@ version = "0.0.0"
dependencies = [
"log",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
"rustc_feature",
"rustc_index",
"rustc_lexer",
"rustc_macros",
"rustc_session",
"rustc_span",
"scoped-tls",
"serialize",
Expand Down
30 changes: 30 additions & 0 deletions src/liballoc/benches/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ pub fn iter_100000(b: &mut Bencher) {
bench_iter(b, 100000);
}

fn bench_iter_mut(b: &mut Bencher, size: i32) {
let mut map = BTreeMap::<i32, i32>::new();
let mut rng = thread_rng();

for _ in 0..size {
map.insert(rng.gen(), rng.gen());
}

b.iter(|| {
for kv in map.iter_mut() {
black_box(kv);
}
});
}

#[bench]
pub fn iter_mut_20(b: &mut Bencher) {
bench_iter_mut(b, 20);
}

#[bench]
pub fn iter_mut_1000(b: &mut Bencher) {
bench_iter_mut(b, 1000);
}

#[bench]
pub fn iter_mut_100000(b: &mut Bencher) {
bench_iter_mut(b, 100000);
}

fn bench_first_and_last(b: &mut Bencher, size: i32) {
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
b.iter(|| {
Expand Down
47 changes: 39 additions & 8 deletions src/liballoc/benches/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@ fn random(n: usize) -> BTreeSet<usize> {
}

fn neg(n: usize) -> BTreeSet<i32> {
let mut set = BTreeSet::new();
for i in -(n as i32)..=-1 {
set.insert(i);
}
let set: BTreeSet<i32> = (-(n as i32)..=-1).collect();
assert_eq!(set.len(), n);
set
}

fn pos(n: usize) -> BTreeSet<i32> {
let mut set = BTreeSet::new();
for i in 1..=(n as i32) {
set.insert(i);
}
let set: BTreeSet<i32> = (1..=(n as i32)).collect();
assert_eq!(set.len(), n);
set
}
Expand Down Expand Up @@ -56,6 +50,43 @@ macro_rules! set_bench {
};
}

const BUILD_SET_SIZE: usize = 100;

#[bench]
pub fn build_and_clear(b: &mut Bencher) {
b.iter(|| pos(BUILD_SET_SIZE).clear())
}

#[bench]
pub fn build_and_drop(b: &mut Bencher) {
b.iter(|| pos(BUILD_SET_SIZE))
}

#[bench]
pub fn build_and_into_iter(b: &mut Bencher) {
b.iter(|| pos(BUILD_SET_SIZE).into_iter().count())
}

#[bench]
pub fn build_and_pop_all(b: &mut Bencher) {
b.iter(|| {
let mut s = pos(BUILD_SET_SIZE);
while s.pop_first().is_some() {}
s
});
}

#[bench]
pub fn build_and_remove_all(b: &mut Bencher) {
b.iter(|| {
let mut s = pos(BUILD_SET_SIZE);
while let Some(elt) = s.iter().copied().next() {
s.remove(&elt);
}
s
});
}

set_bench! {intersection_100_neg_vs_100_pos, intersection, count, [neg(100), pos(100)]}
set_bench! {intersection_100_neg_vs_10k_pos, intersection, count, [neg(100), pos(10_000)]}
set_bench! {intersection_100_pos_vs_100_neg, intersection, count, [pos(100), neg(100)]}
Expand Down
5 changes: 5 additions & 0 deletions src/libcore/iter/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ pub fn repeat_with<A, F: FnMut() -> A>(repeater: F) -> RepeatWith<F> {
#[stable(feature = "iter_empty", since = "1.2.0")]
pub struct Empty<T>(marker::PhantomData<T>);

#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
unsafe impl<T> Send for Empty<T> {}
#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
unsafe impl<T> Sync for Empty<T> {}

#[stable(feature = "core_impl_debug", since = "1.9.0")]
impl<T> fmt::Debug for Empty<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rustc-rayon = "0.3.0"
rustc-rayon-core = "0.3.0"
polonius-engine = "0.11.0"
rustc_apfloat = { path = "../librustc_apfloat" }
rustc_attr = { path = "../librustc_attr" }
rustc_feature = { path = "../librustc_feature" }
rustc_hir = { path = "../librustc_hir" }
rustc_target = { path = "../librustc_target" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use rustc_data_structures::stable_hasher::StableHasher;
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_index::vec::IndexVec;
use rustc_session::node_id::NodeMap;
use rustc_session::CrateDisambiguator;
use rustc_span::hygiene::ExpnId;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use syntax::ast;
use syntax::node_id::NodeMap;

use std::borrow::Borrow;
use std::fmt::Write;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
use crate::hir::map::DefPathHash;
use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
use rustc_attr as attr;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
use smallvec::SmallVec;
use std::mem;
use syntax::attr;

impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/codegen_fn_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::mir::mono::Linkage;
use rustc_attr::{InlineAttr, OptimizeAttr};
use rustc_span::symbol::Symbol;
use syntax::attr::{InlineAttr, OptimizeAttr};

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub struct CodegenFnAttrs {
Expand Down
Loading

0 comments on commit 29f163e

Please sign in to comment.