Skip to content

Commit 4fd0cc1

Browse files
committed
Merge branch 'btreeset_intersection_benchmarks' into btreeset_intersection
2 parents 0186d90 + 09a2454 commit 4fd0cc1

File tree

179 files changed

+2113
-864
lines changed

Some content is hidden

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

179 files changed

+2113
-864
lines changed

.gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
url = https://github.com/rust-lang-nursery/rustfmt.git
2525
[submodule "src/tools/miri"]
2626
path = src/tools/miri
27-
url = https://github.com/solson/miri.git
27+
url = https://github.com/rust-lang/miri.git
2828
[submodule "src/doc/rust-by-example"]
2929
path = src/doc/rust-by-example
3030
url = https://github.com/rust-lang/rust-by-example.git
@@ -46,4 +46,4 @@
4646
branch = rustc/8.0-2019-01-16
4747
[submodule "src/doc/embedded-book"]
4848
path = src/doc/embedded-book
49-
url = https://github.com/rust-embedded/book.git
49+
url = https://github.com/rust-embedded/book.git

Cargo.lock

+141-95
Large diffs are not rendered by default.

src/doc/rustc/src/command-line-arguments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ This flag prints out various information about the compiler.
4242

4343
## `-g`: include debug information
4444

45-
A synonym for `-C debug-level=2`.
45+
A synonym for `-C debuginfo=2`, for more see [here](codegen-options/index.html#debuginfo).
4646

4747
## `-O`: optimize your code
4848

49-
A synonym for `-C opt-level=2`.
49+
A synonym for `-C opt-level=2`, for more see [here](codegen-options/index.html#opt-level).
5050

5151
## `-o`: filename of the output
5252

src/doc/rustc/src/lints/levels.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ This lint level gives you that.
9090
'forbid' is a special lint level that's stronger than 'deny'. It's the same
9191
as 'deny' in that a lint at this level will produce an error, but unlike the
9292
'deny' level, the 'forbid' level can not be overridden to be anything lower
93-
than an error.
93+
than an error. However, lint levels may still be capped with `--cap-lints`
94+
(see below) so `rustc --cap-lints warn` will make lints set to 'forbid' just
95+
warn.
9496

9597
## Configuring warning levels
9698

src/doc/rustdoc/src/documentation-tests.md

+17
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,23 @@ appears to the reader as the initial idea but works with doc tests:
236236
/// ```
237237
```
238238

239+
As of version 1.34.0, one can also omit the `fn main()`, but you will have to
240+
disambiguate the error type:
241+
242+
```ignore
243+
/// ```
244+
/// use std::io;
245+
/// let mut input = String::new();
246+
/// io::stdin().read_line(&mut input)?;
247+
/// # Ok::<(), io:Error>(())
248+
/// ```
249+
```
250+
251+
This is an unfortunate consequence of the `?` operator adding an implicit
252+
conversion, so type inference fails because the type is not unique. Please note
253+
that you must write the `(())` in one sequence without intermediate whitespace
254+
so that rustdoc understands you want an implicit `Result`-returning function.
255+
239256
## Documenting macros
240257

241258
Here’s an example of documenting a macro:

src/liballoc/benches/btree/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
mod map;
2+
mod set;

src/liballoc/benches/btree/set.rs

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
use std::collections::BTreeSet;
2+
3+
use rand::{thread_rng, Rng};
4+
use test::{black_box, Bencher};
5+
6+
fn random(n1: u32, n2: u32) -> [BTreeSet<usize>; 2] {
7+
let mut rng = thread_rng();
8+
let mut set1 = BTreeSet::new();
9+
let mut set2 = BTreeSet::new();
10+
for _ in 0..n1 {
11+
let i = rng.gen::<usize>();
12+
set1.insert(i);
13+
}
14+
for _ in 0..n2 {
15+
let i = rng.gen::<usize>();
16+
set2.insert(i);
17+
}
18+
[set1, set2]
19+
}
20+
21+
fn staggered(n1: u32, n2: u32) -> [BTreeSet<u32>; 2] {
22+
let mut even = BTreeSet::new();
23+
let mut odd = BTreeSet::new();
24+
for i in 0..n1 {
25+
even.insert(i * 2);
26+
}
27+
for i in 0..n2 {
28+
odd.insert(i * 2 + 1);
29+
}
30+
[even, odd]
31+
}
32+
33+
fn neg_vs_pos(n1: u32, n2: u32) -> [BTreeSet<i32>; 2] {
34+
let mut neg = BTreeSet::new();
35+
let mut pos = BTreeSet::new();
36+
for i in -(n1 as i32)..=-1 {
37+
neg.insert(i);
38+
}
39+
for i in 1..=(n2 as i32) {
40+
pos.insert(i);
41+
}
42+
[neg, pos]
43+
}
44+
45+
fn pos_vs_neg(n1: u32, n2: u32) -> [BTreeSet<i32>; 2] {
46+
let mut neg = BTreeSet::new();
47+
let mut pos = BTreeSet::new();
48+
for i in -(n1 as i32)..=-1 {
49+
neg.insert(i);
50+
}
51+
for i in 1..=(n2 as i32) {
52+
pos.insert(i);
53+
}
54+
[pos, neg]
55+
}
56+
57+
macro_rules! set_intersection_bench {
58+
($name: ident, $sets: expr) => {
59+
#[bench]
60+
pub fn $name(b: &mut Bencher) {
61+
// setup
62+
let sets = $sets;
63+
64+
// measure
65+
b.iter(|| {
66+
let x = sets[0].intersection(&sets[1]).count();
67+
black_box(x);
68+
})
69+
}
70+
};
71+
}
72+
73+
set_intersection_bench! {intersect_random_100, random(100, 100)}
74+
set_intersection_bench! {intersect_random_10k, random(10_000, 10_000)}
75+
set_intersection_bench! {intersect_random_10_vs_10k, random(10, 10_000)}
76+
set_intersection_bench! {intersect_random_10k_vs_10, random(10_000, 10)}
77+
set_intersection_bench! {intersect_staggered_100, staggered(100, 100)}
78+
set_intersection_bench! {intersect_staggered_10k, staggered(10_000, 10_000)}
79+
set_intersection_bench! {intersect_staggered_10_vs_10k, staggered(10, 10_000)}
80+
set_intersection_bench! {intersect_staggered_10k_vs_10, staggered(10_000, 10)}
81+
set_intersection_bench! {intersect_neg_vs_pos_100, neg_vs_pos(100, 100)}
82+
set_intersection_bench! {intersect_neg_vs_pos_10k, neg_vs_pos(10_000, 10_000)}
83+
set_intersection_bench! {intersect_neg_vs_pos_10_vs_10k,neg_vs_pos(10, 10_000)}
84+
set_intersection_bench! {intersect_neg_vs_pos_10k_vs_10,neg_vs_pos(10_000, 10)}
85+
set_intersection_bench! {intersect_pos_vs_neg_100, pos_vs_neg(100, 100)}
86+
set_intersection_bench! {intersect_pos_vs_neg_10k, pos_vs_neg(10_000, 10_000)}
87+
set_intersection_bench! {intersect_pos_vs_neg_10_vs_10k,pos_vs_neg(10, 10_000)}
88+
set_intersection_bench! {intersect_pos_vs_neg_10k_vs_10,pos_vs_neg(10_000, 10)}

src/liballoc/borrow.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ pub enum Cow<'a, B: ?Sized + 'a>
182182
}
183183

184184
#[stable(feature = "rust1", since = "1.0.0")]
185-
impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> {
186-
fn clone(&self) -> Cow<'a, B> {
185+
impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
186+
fn clone(&self) -> Self {
187187
match *self {
188188
Borrowed(b) => Borrowed(b),
189189
Owned(ref o) => {
@@ -193,7 +193,7 @@ impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> {
193193
}
194194
}
195195

196-
fn clone_from(&mut self, source: &Cow<'a, B>) {
196+
fn clone_from(&mut self, source: &Self) {
197197
if let Owned(ref mut dest) = *self {
198198
if let Owned(ref o) = *source {
199199
o.borrow().clone_into(dest);
@@ -296,11 +296,11 @@ impl<B: ?Sized + ToOwned> Deref for Cow<'_, B> {
296296
impl<B: ?Sized> Eq for Cow<'_, B> where B: Eq + ToOwned {}
297297

298298
#[stable(feature = "rust1", since = "1.0.0")]
299-
impl<'a, B: ?Sized> Ord for Cow<'a, B>
299+
impl<B: ?Sized> Ord for Cow<'_, B>
300300
where B: Ord + ToOwned
301301
{
302302
#[inline]
303-
fn cmp(&self, other: &Cow<'a, B>) -> Ordering {
303+
fn cmp(&self, other: &Self) -> Ordering {
304304
Ord::cmp(&**self, &**other)
305305
}
306306
}
@@ -353,18 +353,18 @@ impl<B: ?Sized> fmt::Display for Cow<'_, B>
353353
}
354354

355355
#[stable(feature = "default", since = "1.11.0")]
356-
impl<'a, B: ?Sized> Default for Cow<'a, B>
356+
impl<B: ?Sized> Default for Cow<'_, B>
357357
where B: ToOwned,
358358
<B as ToOwned>::Owned: Default
359359
{
360360
/// Creates an owned Cow<'a, B> with the default value for the contained owned value.
361-
fn default() -> Cow<'a, B> {
361+
fn default() -> Self {
362362
Owned(<B as ToOwned>::Owned::default())
363363
}
364364
}
365365

366366
#[stable(feature = "rust1", since = "1.0.0")]
367-
impl<'a, B: ?Sized> Hash for Cow<'a, B>
367+
impl<B: ?Sized> Hash for Cow<'_, B>
368368
where B: Hash + ToOwned
369369
{
370370
#[inline]

src/liballoc/collections/binary_heap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,8 @@ impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
947947

948948
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
949949
#[stable(feature = "rust1", since = "1.0.0")]
950-
impl<'a, T> Clone for Iter<'a, T> {
951-
fn clone(&self) -> Iter<'a, T> {
950+
impl<T> Clone for Iter<'_, T> {
951+
fn clone(&self) -> Self {
952952
Iter { iter: self.iter.clone() }
953953
}
954954
}

src/liballoc/collections/btree/map.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,8 @@ impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
12181218
}
12191219

12201220
#[stable(feature = "rust1", since = "1.0.0")]
1221-
impl<'a, K, V> Clone for Iter<'a, K, V> {
1222-
fn clone(&self) -> Iter<'a, K, V> {
1221+
impl<K, V> Clone for Iter<'_, K, V> {
1222+
fn clone(&self) -> Self {
12231223
Iter {
12241224
range: self.range.clone(),
12251225
length: self.length,
@@ -1441,8 +1441,8 @@ impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
14411441
impl<K, V> FusedIterator for Keys<'_, K, V> {}
14421442

14431443
#[stable(feature = "rust1", since = "1.0.0")]
1444-
impl<'a, K, V> Clone for Keys<'a, K, V> {
1445-
fn clone(&self) -> Keys<'a, K, V> {
1444+
impl<K, V> Clone for Keys<'_, K, V> {
1445+
fn clone(&self) -> Self {
14461446
Keys { inner: self.inner.clone() }
14471447
}
14481448
}
@@ -1478,8 +1478,8 @@ impl<K, V> ExactSizeIterator for Values<'_, K, V> {
14781478
impl<K, V> FusedIterator for Values<'_, K, V> {}
14791479

14801480
#[stable(feature = "rust1", since = "1.0.0")]
1481-
impl<'a, K, V> Clone for Values<'a, K, V> {
1482-
fn clone(&self) -> Values<'a, K, V> {
1481+
impl<K, V> Clone for Values<'_, K, V> {
1482+
fn clone(&self) -> Self {
14831483
Values { inner: self.inner.clone() }
14841484
}
14851485
}
@@ -1606,8 +1606,8 @@ impl<'a, K, V> Range<'a, K, V> {
16061606
impl<K, V> FusedIterator for Range<'_, K, V> {}
16071607

16081608
#[stable(feature = "btree_range", since = "1.17.0")]
1609-
impl<'a, K, V> Clone for Range<'a, K, V> {
1610-
fn clone(&self) -> Range<'a, K, V> {
1609+
impl<K, V> Clone for Range<'_, K, V> {
1610+
fn clone(&self) -> Self {
16111611
Range {
16121612
front: self.front,
16131613
back: self.back,

src/liballoc/collections/btree/set.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,8 @@ impl<T: Debug> Debug for BTreeSet<T> {
941941
}
942942

943943
#[stable(feature = "rust1", since = "1.0.0")]
944-
impl<'a, T> Clone for Iter<'a, T> {
945-
fn clone(&self) -> Iter<'a, T> {
944+
impl<T> Clone for Iter<'_, T> {
945+
fn clone(&self) -> Self {
946946
Iter { iter: self.iter.clone() }
947947
}
948948
}
@@ -997,8 +997,8 @@ impl<T> ExactSizeIterator for IntoIter<T> {
997997
impl<T> FusedIterator for IntoIter<T> {}
998998

999999
#[stable(feature = "btree_range", since = "1.17.0")]
1000-
impl<'a, T> Clone for Range<'a, T> {
1001-
fn clone(&self) -> Range<'a, T> {
1000+
impl<T> Clone for Range<'_, T> {
1001+
fn clone(&self) -> Self {
10021002
Range { iter: self.iter.clone() }
10031003
}
10041004
}
@@ -1032,8 +1032,8 @@ fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>, short: Ordering, long: Ordering
10321032
}
10331033

10341034
#[stable(feature = "rust1", since = "1.0.0")]
1035-
impl<'a, T> Clone for Difference<'a, T> {
1036-
fn clone(&self) -> Difference<'a, T> {
1035+
impl<T> Clone for Difference<'_, T> {
1036+
fn clone(&self) -> Self {
10371037
Difference {
10381038
a: self.a.clone(),
10391039
b: self.b.clone(),
@@ -1070,8 +1070,8 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
10701070
impl<T: Ord> FusedIterator for Difference<'_, T> {}
10711071

10721072
#[stable(feature = "rust1", since = "1.0.0")]
1073-
impl<'a, T> Clone for SymmetricDifference<'a, T> {
1074-
fn clone(&self) -> SymmetricDifference<'a, T> {
1073+
impl<T> Clone for SymmetricDifference<'_, T> {
1074+
fn clone(&self) -> Self {
10751075
SymmetricDifference {
10761076
a: self.a.clone(),
10771077
b: self.b.clone(),
@@ -1112,8 +1112,8 @@ impl<'a, T> Clone for IntersectionOther<'a, T> {
11121112
}
11131113
}
11141114
#[stable(feature = "rust1", since = "1.0.0")]
1115-
impl<'a, T> Clone for Intersection<'a, T> {
1116-
fn clone(&self) -> Intersection<'a, T> {
1115+
impl<T> Clone for Intersection<'_, T> {
1116+
fn clone(&self) -> Self {
11171117
Intersection {
11181118
a: self.a.clone(),
11191119
b: self.b.clone(),
@@ -1162,8 +1162,8 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
11621162
impl<T: Ord> FusedIterator for Intersection<'_, T> {}
11631163

11641164
#[stable(feature = "rust1", since = "1.0.0")]
1165-
impl<'a, T> Clone for Union<'a, T> {
1166-
fn clone(&self) -> Union<'a, T> {
1165+
impl<T> Clone for Union<'_, T> {
1166+
fn clone(&self) -> Self {
11671167
Union {
11681168
a: self.a.clone(),
11691169
b: self.b.clone(),

src/liballoc/collections/linked_list.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1200,16 +1200,16 @@ unsafe impl<T: Send> Send for LinkedList<T> {}
12001200
unsafe impl<T: Sync> Sync for LinkedList<T> {}
12011201

12021202
#[stable(feature = "rust1", since = "1.0.0")]
1203-
unsafe impl<'a, T: Sync> Send for Iter<'a, T> {}
1203+
unsafe impl<T: Sync> Send for Iter<'_, T> {}
12041204

12051205
#[stable(feature = "rust1", since = "1.0.0")]
1206-
unsafe impl<'a, T: Sync> Sync for Iter<'a, T> {}
1206+
unsafe impl<T: Sync> Sync for Iter<'_, T> {}
12071207

12081208
#[stable(feature = "rust1", since = "1.0.0")]
1209-
unsafe impl<'a, T: Send> Send for IterMut<'a, T> {}
1209+
unsafe impl<T: Send> Send for IterMut<'_, T> {}
12101210

12111211
#[stable(feature = "rust1", since = "1.0.0")]
1212-
unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {}
1212+
unsafe impl<T: Sync> Sync for IterMut<'_, T> {}
12131213

12141214
#[cfg(test)]
12151215
mod tests {

src/liballoc/collections/vec_deque.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2132,8 +2132,8 @@ impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
21322132

21332133
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
21342134
#[stable(feature = "rust1", since = "1.0.0")]
2135-
impl<'a, T> Clone for Iter<'a, T> {
2136-
fn clone(&self) -> Iter<'a, T> {
2135+
impl<T> Clone for Iter<'_, T> {
2136+
fn clone(&self) -> Self {
21372137
Iter {
21382138
ring: self.ring,
21392139
tail: self.tail,
@@ -2225,7 +2225,7 @@ pub struct IterMut<'a, T: 'a> {
22252225
}
22262226

22272227
#[stable(feature = "collection_debug", since = "1.17.0")]
2228-
impl<'a, T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
2228+
impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
22292229
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22302230
let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail);
22312231
f.debug_tuple("IterMut")

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2455,7 +2455,7 @@ pub struct Drain<'a, T: 'a> {
24552455
}
24562456

24572457
#[stable(feature = "collection_debug", since = "1.17.0")]
2458-
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> {
2458+
impl<T: fmt::Debug> fmt::Debug for Drain<'_, T> {
24592459
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24602460
f.debug_tuple("Drain")
24612461
.field(&self.iter.as_slice())

0 commit comments

Comments
 (0)