Skip to content

Commit 29f163e

Browse files
committed
Auto merge of #68360 - Dylan-DPC:rollup-iej35pz, r=Dylan-DPC
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
2 parents 6250d56 + cfc0f54 commit 29f163e

File tree

146 files changed

+547
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+547
-388
lines changed

Cargo.lock

+56-5
Original file line numberDiff line numberDiff line change
@@ -3091,6 +3091,7 @@ dependencies = [
30913091
"rustc-rayon",
30923092
"rustc-rayon-core",
30933093
"rustc_apfloat",
3094+
"rustc_attr",
30943095
"rustc_data_structures",
30953096
"rustc_error_codes",
30963097
"rustc_errors",
@@ -3357,6 +3358,7 @@ version = "0.0.0"
33573358
dependencies = [
33583359
"log",
33593360
"rustc",
3361+
"rustc_ast_pretty",
33603362
"rustc_data_structures",
33613363
"rustc_error_codes",
33623364
"rustc_errors",
@@ -3374,6 +3376,8 @@ name = "rustc_ast_passes"
33743376
version = "0.0.0"
33753377
dependencies = [
33763378
"log",
3379+
"rustc_ast_pretty",
3380+
"rustc_attr",
33773381
"rustc_data_structures",
33783382
"rustc_error_codes",
33793383
"rustc_errors",
@@ -3384,12 +3388,41 @@ dependencies = [
33843388
"syntax",
33853389
]
33863390

3391+
[[package]]
3392+
name = "rustc_ast_pretty"
3393+
version = "0.0.0"
3394+
dependencies = [
3395+
"log",
3396+
"rustc_data_structures",
3397+
"rustc_span",
3398+
"syntax",
3399+
]
3400+
3401+
[[package]]
3402+
name = "rustc_attr"
3403+
version = "0.0.0"
3404+
dependencies = [
3405+
"rustc_ast_pretty",
3406+
"rustc_data_structures",
3407+
"rustc_error_codes",
3408+
"rustc_errors",
3409+
"rustc_feature",
3410+
"rustc_macros",
3411+
"rustc_session",
3412+
"rustc_span",
3413+
"serialize",
3414+
"smallvec 1.0.0",
3415+
"syntax",
3416+
]
3417+
33873418
[[package]]
33883419
name = "rustc_builtin_macros"
33893420
version = "0.0.0"
33903421
dependencies = [
33913422
"fmt_macros",
33923423
"log",
3424+
"rustc_ast_pretty",
3425+
"rustc_attr",
33933426
"rustc_data_structures",
33943427
"rustc_error_codes",
33953428
"rustc_errors",
@@ -3413,6 +3446,7 @@ dependencies = [
34133446
"log",
34143447
"rustc",
34153448
"rustc-demangle",
3449+
"rustc_attr",
34163450
"rustc_codegen_ssa",
34173451
"rustc_codegen_utils",
34183452
"rustc_data_structures",
@@ -3443,6 +3477,7 @@ dependencies = [
34433477
"num_cpus",
34443478
"rustc",
34453479
"rustc_apfloat",
3480+
"rustc_attr",
34463481
"rustc_codegen_utils",
34473482
"rustc_data_structures",
34483483
"rustc_error_codes",
@@ -3508,6 +3543,7 @@ dependencies = [
35083543
"lazy_static 1.3.0",
35093544
"log",
35103545
"rustc",
3546+
"rustc_ast_pretty",
35113547
"rustc_codegen_utils",
35123548
"rustc_data_structures",
35133549
"rustc_error_codes",
@@ -3554,6 +3590,8 @@ version = "0.0.0"
35543590
dependencies = [
35553591
"log",
35563592
"rustc_ast_passes",
3593+
"rustc_ast_pretty",
3594+
"rustc_attr",
35573595
"rustc_data_structures",
35583596
"rustc_errors",
35593597
"rustc_feature",
@@ -3583,11 +3621,11 @@ version = "0.0.0"
35833621
name = "rustc_hir"
35843622
version = "0.0.0"
35853623
dependencies = [
3624+
"rustc_ast_pretty",
35863625
"rustc_data_structures",
35873626
"rustc_errors",
35883627
"rustc_index",
35893628
"rustc_macros",
3590-
"rustc_session",
35913629
"rustc_span",
35923630
"rustc_target",
35933631
"serialize",
@@ -3630,6 +3668,7 @@ dependencies = [
36303668
"rustc-rayon",
36313669
"rustc_ast_lowering",
36323670
"rustc_ast_passes",
3671+
"rustc_attr",
36333672
"rustc_builtin_macros",
36343673
"rustc_codegen_llvm",
36353674
"rustc_codegen_ssa",
@@ -3674,6 +3713,8 @@ version = "0.0.0"
36743713
dependencies = [
36753714
"log",
36763715
"rustc",
3716+
"rustc_ast_pretty",
3717+
"rustc_attr",
36773718
"rustc_data_structures",
36783719
"rustc_error_codes",
36793720
"rustc_errors",
@@ -3715,6 +3756,8 @@ dependencies = [
37153756
"log",
37163757
"memmap",
37173758
"rustc",
3759+
"rustc_ast_pretty",
3760+
"rustc_attr",
37183761
"rustc_data_structures",
37193762
"rustc_error_codes",
37203763
"rustc_errors",
@@ -3743,6 +3786,8 @@ dependencies = [
37433786
"polonius-engine",
37443787
"rustc",
37453788
"rustc_apfloat",
3789+
"rustc_ast_pretty",
3790+
"rustc_attr",
37463791
"rustc_data_structures",
37473792
"rustc_error_codes",
37483793
"rustc_errors",
@@ -3766,6 +3811,7 @@ dependencies = [
37663811
"log",
37673812
"rustc",
37683813
"rustc_apfloat",
3814+
"rustc_attr",
37693815
"rustc_data_structures",
37703816
"rustc_error_codes",
37713817
"rustc_errors",
@@ -3785,6 +3831,8 @@ version = "0.0.0"
37853831
dependencies = [
37863832
"bitflags",
37873833
"log",
3834+
"rustc_ast_pretty",
3835+
"rustc_attr",
37883836
"rustc_data_structures",
37893837
"rustc_error_codes",
37903838
"rustc_errors",
@@ -3803,6 +3851,7 @@ version = "0.0.0"
38033851
dependencies = [
38043852
"log",
38053853
"rustc",
3854+
"rustc_attr",
38063855
"rustc_data_structures",
38073856
"rustc_error_codes",
38083857
"rustc_errors",
@@ -3835,6 +3884,7 @@ version = "0.0.0"
38353884
dependencies = [
38363885
"log",
38373886
"rustc",
3887+
"rustc_attr",
38383888
"rustc_data_structures",
38393889
"rustc_error_codes",
38403890
"rustc_errors",
@@ -3853,6 +3903,8 @@ dependencies = [
38533903
"log",
38543904
"rustc",
38553905
"rustc_ast_lowering",
3906+
"rustc_ast_pretty",
3907+
"rustc_attr",
38563908
"rustc_data_structures",
38573909
"rustc_error_codes",
38583910
"rustc_errors",
@@ -3874,6 +3926,7 @@ dependencies = [
38743926
"rls-data",
38753927
"rls-span",
38763928
"rustc",
3929+
"rustc_ast_pretty",
38773930
"rustc_codegen_utils",
38783931
"rustc_data_structures",
38793932
"rustc_hir",
@@ -3898,6 +3951,7 @@ dependencies = [
38983951
"rustc_span",
38993952
"rustc_target",
39003953
"serialize",
3954+
"syntax",
39013955
]
39023956

39033957
[[package]]
@@ -3972,6 +4026,7 @@ dependencies = [
39724026
"arena",
39734027
"log",
39744028
"rustc",
4029+
"rustc_attr",
39754030
"rustc_data_structures",
39764031
"rustc_error_codes",
39774032
"rustc_errors",
@@ -4493,13 +4548,9 @@ version = "0.0.0"
44934548
dependencies = [
44944549
"log",
44954550
"rustc_data_structures",
4496-
"rustc_error_codes",
4497-
"rustc_errors",
4498-
"rustc_feature",
44994551
"rustc_index",
45004552
"rustc_lexer",
45014553
"rustc_macros",
4502-
"rustc_session",
45034554
"rustc_span",
45044555
"scoped-tls",
45054556
"serialize",

src/liballoc/benches/btree/map.rs

+30
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@ pub fn iter_100000(b: &mut Bencher) {
146146
bench_iter(b, 100000);
147147
}
148148

149+
fn bench_iter_mut(b: &mut Bencher, size: i32) {
150+
let mut map = BTreeMap::<i32, i32>::new();
151+
let mut rng = thread_rng();
152+
153+
for _ in 0..size {
154+
map.insert(rng.gen(), rng.gen());
155+
}
156+
157+
b.iter(|| {
158+
for kv in map.iter_mut() {
159+
black_box(kv);
160+
}
161+
});
162+
}
163+
164+
#[bench]
165+
pub fn iter_mut_20(b: &mut Bencher) {
166+
bench_iter_mut(b, 20);
167+
}
168+
169+
#[bench]
170+
pub fn iter_mut_1000(b: &mut Bencher) {
171+
bench_iter_mut(b, 1000);
172+
}
173+
174+
#[bench]
175+
pub fn iter_mut_100000(b: &mut Bencher) {
176+
bench_iter_mut(b, 100000);
177+
}
178+
149179
fn bench_first_and_last(b: &mut Bencher, size: i32) {
150180
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
151181
b.iter(|| {

src/liballoc/benches/btree/set.rs

+39-8
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,13 @@ fn random(n: usize) -> BTreeSet<usize> {
1414
}
1515

1616
fn neg(n: usize) -> BTreeSet<i32> {
17-
let mut set = BTreeSet::new();
18-
for i in -(n as i32)..=-1 {
19-
set.insert(i);
20-
}
17+
let set: BTreeSet<i32> = (-(n as i32)..=-1).collect();
2118
assert_eq!(set.len(), n);
2219
set
2320
}
2421

2522
fn pos(n: usize) -> BTreeSet<i32> {
26-
let mut set = BTreeSet::new();
27-
for i in 1..=(n as i32) {
28-
set.insert(i);
29-
}
23+
let set: BTreeSet<i32> = (1..=(n as i32)).collect();
3024
assert_eq!(set.len(), n);
3125
set
3226
}
@@ -56,6 +50,43 @@ macro_rules! set_bench {
5650
};
5751
}
5852

53+
const BUILD_SET_SIZE: usize = 100;
54+
55+
#[bench]
56+
pub fn build_and_clear(b: &mut Bencher) {
57+
b.iter(|| pos(BUILD_SET_SIZE).clear())
58+
}
59+
60+
#[bench]
61+
pub fn build_and_drop(b: &mut Bencher) {
62+
b.iter(|| pos(BUILD_SET_SIZE))
63+
}
64+
65+
#[bench]
66+
pub fn build_and_into_iter(b: &mut Bencher) {
67+
b.iter(|| pos(BUILD_SET_SIZE).into_iter().count())
68+
}
69+
70+
#[bench]
71+
pub fn build_and_pop_all(b: &mut Bencher) {
72+
b.iter(|| {
73+
let mut s = pos(BUILD_SET_SIZE);
74+
while s.pop_first().is_some() {}
75+
s
76+
});
77+
}
78+
79+
#[bench]
80+
pub fn build_and_remove_all(b: &mut Bencher) {
81+
b.iter(|| {
82+
let mut s = pos(BUILD_SET_SIZE);
83+
while let Some(elt) = s.iter().copied().next() {
84+
s.remove(&elt);
85+
}
86+
s
87+
});
88+
}
89+
5990
set_bench! {intersection_100_neg_vs_100_pos, intersection, count, [neg(100), pos(100)]}
6091
set_bench! {intersection_100_neg_vs_10k_pos, intersection, count, [neg(100), pos(10_000)]}
6192
set_bench! {intersection_100_pos_vs_100_neg, intersection, count, [pos(100), neg(100)]}

src/libcore/iter/sources.rs

+5
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ pub fn repeat_with<A, F: FnMut() -> A>(repeater: F) -> RepeatWith<F> {
208208
#[stable(feature = "iter_empty", since = "1.2.0")]
209209
pub struct Empty<T>(marker::PhantomData<T>);
210210

211+
#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
212+
unsafe impl<T> Send for Empty<T> {}
213+
#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
214+
unsafe impl<T> Sync for Empty<T> {}
215+
211216
#[stable(feature = "core_impl_debug", since = "1.9.0")]
212217
impl<T> fmt::Debug for Empty<T> {
213218
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

src/librustc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ rustc-rayon = "0.3.0"
2121
rustc-rayon-core = "0.3.0"
2222
polonius-engine = "0.11.0"
2323
rustc_apfloat = { path = "../librustc_apfloat" }
24+
rustc_attr = { path = "../librustc_attr" }
2425
rustc_feature = { path = "../librustc_feature" }
2526
rustc_hir = { path = "../librustc_hir" }
2627
rustc_target = { path = "../librustc_target" }

src/librustc/hir/map/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use rustc_data_structures::stable_hasher::StableHasher;
1010
use rustc_hir as hir;
1111
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
1212
use rustc_index::vec::IndexVec;
13-
use rustc_session::node_id::NodeMap;
1413
use rustc_session::CrateDisambiguator;
1514
use rustc_span::hygiene::ExpnId;
1615
use rustc_span::symbol::{sym, Symbol};
1716
use rustc_span::Span;
1817
use syntax::ast;
18+
use syntax::node_id::NodeMap;
1919

2020
use std::borrow::Borrow;
2121
use std::fmt::Write;

src/librustc/ich/impls_hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
44
use crate::hir::map::DefPathHash;
55
use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
6+
use rustc_attr as attr;
67
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
78
use rustc_hir as hir;
89
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
910
use smallvec::SmallVec;
1011
use std::mem;
11-
use syntax::attr;
1212

1313
impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
1414
#[inline]

src/librustc/middle/codegen_fn_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::mir::mono::Linkage;
2+
use rustc_attr::{InlineAttr, OptimizeAttr};
23
use rustc_span::symbol::Symbol;
3-
use syntax::attr::{InlineAttr, OptimizeAttr};
44

55
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
66
pub struct CodegenFnAttrs {

0 commit comments

Comments
 (0)