Skip to content

Rollup of 5 pull requests #68360

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

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3ada8ae
Add more BTreeMap/BTreeSet benchmarks regarding iteration
ssomers Jan 12, 2020
a1a0aea
clean up E0195 explanation
GuillaumeGomez Jan 15, 2020
6f1bdb4
clean up E0197 explanation
GuillaumeGomez Jan 15, 2020
9b4823d
{syntax -> rustc_ast_passes}::node_count
Centril Jan 11, 2020
dc457c6
syntax: move GLOBALS to attr module
Centril Jan 11, 2020
c124e32
pretty: remove ParseSess dependency
Centril Jan 11, 2020
d9bbebc
syntax: simplify HasAttrs code
Centril Jan 11, 2020
a7f6cc7
Move builtin attribute logic to new rustc_attr crate.
Centril Jan 11, 2020
6164f5c
1. move node_id to syntax
Centril Jan 11, 2020
6a6f419
1. move allow_internal_unstable to rustc_attr
Centril Jan 11, 2020
e68df02
syntax::print -> new crate rustc_ast_pretty
Centril Jan 11, 2020
1187ccd
pacify the parallel compiler
Centril Jan 17, 2020
279e214
remove rustc_ast_pretty dep from rustc
Centril Jan 17, 2020
a70b240
Make iter::Empty<T> implement Send and Sync for any T
KamilaBorowska Jan 18, 2020
d7a18f8
Add a test for iter::empty::<*mut i32> being Sync and Send
KamilaBorowska Jan 16, 2019
e7a7964
syntax: reexport attr globals
Centril Jan 18, 2020
5aaf0be
pretty: injected_crate_name -> has_injected_crate
Centril Jan 18, 2020
a67d36f
fix fallout in tests
Centril Jan 18, 2020
e1f70f7
[const-prop] Remove useless typedef
wesleywiser Jan 18, 2020
a957f0d
[const-prop] Run `x.py fmt`
wesleywiser Jan 18, 2020
1d25bd2
Rollup merge of #67682 - wesleywiser:remove_opty_const_typedef, r=Dyl…
Dylan-DPC Jan 19, 2020
a9a89e1
Rollup merge of #68133 - Centril:slimmer-syntax, r=petrochenkov
Dylan-DPC Jan 19, 2020
f78b3e4
Rollup merge of #68154 - ssomers:btreemap_navigation_benches, r=Mark-…
Dylan-DPC Jan 19, 2020
013f253
Rollup merge of #68247 - GuillaumeGomez:clean-up-err-codes, r=Dylan-DPC
Dylan-DPC Jan 19, 2020
cfc0f54
Rollup merge of #68348 - xfix:patch-14, r=nagisa
Dylan-DPC Jan 19, 2020
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
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