From c4f4639e1a2eb07d17e7393a1c7f0594f0c11faf Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Thu, 23 Jul 2020 16:30:54 +0200 Subject: [PATCH 01/15] Remove into_slices and its unsafe block --- library/alloc/src/collections/btree/node.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index f7bd64608d63c..9352c5806a48f 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -466,12 +466,6 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { fn into_val_slice(self) -> &'a [V] { unsafe { slice::from_raw_parts(MaybeUninit::first_ptr(&self.as_leaf().vals), self.len()) } } - - fn into_slices(self) -> (&'a [K], &'a [V]) { - // SAFETY: equivalent to reborrow() except not requiring Type: 'a - let k = unsafe { ptr::read(&self) }; - (k.into_key_slice(), self.into_val_slice()) - } } impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { @@ -980,10 +974,9 @@ impl Handle, marke impl<'a, K: 'a, V: 'a, NodeType> Handle, K, V, NodeType>, marker::KV> { pub fn into_kv(self) -> (&'a K, &'a V) { - unsafe { - let (keys, vals) = self.node.into_slices(); - (keys.get_unchecked(self.idx), vals.get_unchecked(self.idx)) - } + let keys = self.node.into_key_slice(); + let vals = self.node.into_val_slice(); + unsafe { (keys.get_unchecked(self.idx), vals.get_unchecked(self.idx)) } } } From 0a62b7dc92978b03150f58db0dd15f98069ad44e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 10:21:52 +0200 Subject: [PATCH 02/15] make some vec_deque tests less exhaustive in Miri --- .../alloc/src/collections/vec_deque/tests.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/tests.rs b/library/alloc/src/collections/vec_deque/tests.rs index e5edfe02a525f..d74f91c752c04 100644 --- a/library/alloc/src/collections/vec_deque/tests.rs +++ b/library/alloc/src/collections/vec_deque/tests.rs @@ -107,7 +107,8 @@ fn test_insert() { let cap = tester.capacity(); // len is the length *after* insertion - for len in 1..cap { + let minlen = if cfg!(miri) { cap - 1 } else { 1 }; // Miri is too slow + for len in minlen..cap { // 0, 1, 2, .., len - 1 let expected = (0..).take(len).collect::>(); for tail_pos in 0..cap { @@ -221,7 +222,8 @@ fn test_remove() { let cap = tester.capacity(); // len is the length *after* removal - for len in 0..cap - 1 { + let minlen = if cfg!(miri) { cap - 2 } else { 0 }; // Miri is too slow + for len in minlen..cap - 1 { // 0, 1, 2, .., len - 1 let expected = (0..).take(len).collect::>(); for tail_pos in 0..cap { @@ -251,7 +253,8 @@ fn test_range() { let mut tester: VecDeque = VecDeque::with_capacity(7); let cap = tester.capacity(); - for len in 0..=cap { + let minlen = if cfg!(miri) { cap - 1 } else { 0 }; // Miri is too slow + for len in minlen..=cap { for tail in 0..=cap { for start in 0..=len { for end in start..=len { @@ -384,7 +387,8 @@ fn test_split_off() { let cap = tester.capacity(); // len is the length *before* splitting - for len in 0..cap { + let minlen = if cfg!(miri) { cap - 1 } else { 0 }; // Miri is too slow + for len in minlen..cap { // index to split at for at in 0..=len { // 0, 1, 2, .., at - 1 (may be empty) @@ -495,8 +499,9 @@ fn test_vec_from_vecdeque() { fn test_clone_from() { let m = vec![1; 8]; let n = vec![2; 12]; - for pfv in 0..8 { - for pfu in 0..8 { + let limit = if cfg!(miri) { 4 } else { 8 }; // Miri is too slow + for pfv in 0..limit { + for pfu in 0..limit { for longer in 0..2 { let (vr, ur) = if longer == 0 { (&m, &n) } else { (&n, &m) }; let mut v = VecDeque::from(vr.clone()); From 7e168a696f23bf3bbb8b23ac83240910a92ff7a3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 10:32:31 +0200 Subject: [PATCH 03/15] reduce slice::panic_safe test size further in Miri --- library/alloc/tests/slice.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index 75b76bb73ed9e..e5675915300da 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -1722,7 +1722,7 @@ fn panic_safe() { let mut rng = thread_rng(); // Miri is too slow - let lens = if cfg!(miri) { (1..10).chain(20..21) } else { (1..20).chain(70..MAX_LEN) }; + let lens = if cfg!(miri) { (1..10).chain(0..0) } else { (1..20).chain(70..MAX_LEN) }; let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] }; for len in lens { From 7468f632ff4bdb34a7422dad66a548d0672c4aa1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 11:52:53 +0200 Subject: [PATCH 04/15] also reduce some libcore test iteration counts --- library/core/tests/num/flt2dec/random.rs | 2 +- library/core/tests/num/flt2dec/strategy/grisu.rs | 1 + library/core/tests/slice.rs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/library/core/tests/num/flt2dec/random.rs b/library/core/tests/num/flt2dec/random.rs index 0ebc0881f5223..e5656eb204c73 100644 --- a/library/core/tests/num/flt2dec/random.rs +++ b/library/core/tests/num/flt2dec/random.rs @@ -188,7 +188,7 @@ fn exact_f32_random_equivalence_test() { fn exact_f64_random_equivalence_test() { use core::num::flt2dec::strategy::dragon::format_exact as fallback; // Miri is too slow - let n = if cfg!(miri) { 3 } else { 1_000 }; + let n = if cfg!(miri) { 2 } else { 1_000 }; for k in 1..21 { f64_random_equivalence_test( diff --git a/library/core/tests/num/flt2dec/strategy/grisu.rs b/library/core/tests/num/flt2dec/strategy/grisu.rs index ff8373c64551b..7e6c8add3339d 100644 --- a/library/core/tests/num/flt2dec/strategy/grisu.rs +++ b/library/core/tests/num/flt2dec/strategy/grisu.rs @@ -2,6 +2,7 @@ use super::super::*; use core::num::flt2dec::strategy::grisu::*; #[test] +#[cfg_attr(miri, ignore)] // Miri is too slow fn test_cached_power() { assert_eq!(CACHED_POW10.first().unwrap().1, CACHED_POW10_FIRST_E); assert_eq!(CACHED_POW10.last().unwrap().1, CACHED_POW10_LAST_E); diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 8e240832c13b8..35502031da437 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -1268,14 +1268,14 @@ fn sort_unstable() { use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng}; // Miri is too slow - let large_range = if cfg!(miri) { 0..0 } else { 500..510 }; + let lens = if cfg!(miri) { (2..20).chain(0..0) } else { (2..25).chain(500..510) }; let rounds = if cfg!(miri) { 1 } else { 100 }; let mut v = [0; 600]; let mut tmp = [0; 600]; let mut rng = StdRng::from_entropy(); - for len in (2..25).chain(large_range) { + for len in lens { let v = &mut v[0..len]; let tmp = &mut tmp[0..len]; From ff0c3a920996ae0b09a652c1c894329f7acdc28d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 14:03:42 +0200 Subject: [PATCH 05/15] expand comments --- library/alloc/tests/slice.rs | 2 +- library/core/tests/slice.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index e5675915300da..147f7f7d0c729 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -1721,7 +1721,7 @@ fn panic_safe() { let mut rng = thread_rng(); - // Miri is too slow + // Miri is too slow (but still need to `chain` to make the types match) let lens = if cfg!(miri) { (1..10).chain(0..0) } else { (1..20).chain(70..MAX_LEN) }; let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] }; diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 35502031da437..4f54ea2bd92e3 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -1267,7 +1267,7 @@ fn sort_unstable() { use core::slice::heapsort; use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng}; - // Miri is too slow + // Miri is too slow (but still need to `chain` to make the types match) let lens = if cfg!(miri) { (2..20).chain(0..0) } else { (2..25).chain(500..510) }; let rounds = if cfg!(miri) { 1 } else { 100 }; From 240ef70c7b2a8f6833355d41001bc65b3a660eb3 Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Sun, 26 Jul 2020 15:01:43 +0200 Subject: [PATCH 06/15] Define forget_type only when relevant --- .../alloc/src/collections/btree/navigate.rs | 4 ++-- library/alloc/src/collections/btree/node.rs | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/library/alloc/src/collections/btree/navigate.rs b/library/alloc/src/collections/btree/navigate.rs index 44f0e25bbd798..0dcb593096467 100644 --- a/library/alloc/src/collections/btree/navigate.rs +++ b/library/alloc/src/collections/btree/navigate.rs @@ -19,7 +19,7 @@ impl Handle, marker::E Ok(internal_kv) => return Ok(internal_kv), Err(last_edge) => match last_edge.into_node().ascend() { Ok(parent_edge) => parent_edge.forget_node_type(), - Err(root) => return Err(root.forget_type()), + Err(root) => return Err(root), }, } } @@ -40,7 +40,7 @@ impl Handle, marker::E Ok(internal_kv) => return Ok(internal_kv), Err(last_edge) => match last_edge.into_node().ascend() { Ok(parent_edge) => parent_edge.forget_node_type(), - Err(root) => return Err(root.forget_type()), + Err(root) => return Err(root), }, } } diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index f7bd64608d63c..6e6423c516945 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -305,12 +305,6 @@ impl NodeRef { self.height } - /// Removes any static information about whether this node is a `Leaf` or an - /// `Internal` node. - pub fn forget_type(self) -> NodeRef { - NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData } - } - /// Temporarily takes out another, immutable reference to the same node. fn reborrow(&self) -> NodeRef, K, V, Type> { NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData } @@ -1362,6 +1356,20 @@ unsafe fn move_edges( } } +impl NodeRef { + /// Removes any static information asserting that this node is a `Leaf` node. + pub fn forget_type(self) -> NodeRef { + NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData } + } +} + +impl NodeRef { + /// Removes any static information asserting that this node is an `Internal` node. + pub fn forget_type(self) -> NodeRef { + NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData } + } +} + impl Handle, marker::Edge> { pub fn forget_node_type( self, From 602f9aab89791ac2e63d0a41731ddf0a9b727f29 Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Sat, 1 Aug 2020 13:10:12 +0200 Subject: [PATCH 07/15] More benchmarks of BTreeMap mutation --- library/alloc/benches/btree/map.rs | 302 +++++++++++++++++++++++++++++ library/alloc/benches/btree/set.rs | 52 ++--- 2 files changed, 332 insertions(+), 22 deletions(-) diff --git a/library/alloc/benches/btree/map.rs b/library/alloc/benches/btree/map.rs index 38d19c59ad186..7c2e5694a62fc 100644 --- a/library/alloc/benches/btree/map.rs +++ b/library/alloc/benches/btree/map.rs @@ -282,3 +282,305 @@ pub fn iter_10k(b: &mut Bencher) { pub fn iter_1m(b: &mut Bencher) { bench_iter(b, 1_000, 1_000_000); } + +const FAT: usize = 256; + +// The returned map has small keys and values. +// Benchmarks on it have a counterpart in set.rs with the same keys and no values at all. +fn slim_map(n: usize) -> BTreeMap { + (0..n).map(|i| (i, i)).collect::>() +} + +// The returned map has small keys and large values. +fn fat_val_map(n: usize) -> BTreeMap { + (0..n).map(|i| (i, [i; FAT])).collect::>() +} + +// The returned map has large keys and values. +fn fat_map(n: usize) -> BTreeMap<[usize; FAT], [usize; FAT]> { + (0..n).map(|i| ([i; FAT], [i; FAT])).collect::>() +} + +#[bench] +pub fn clone_slim_100(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| src.clone()) +} + +#[bench] +pub fn clone_slim_100_and_clear(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| src.clone().clear()) +} + +#[bench] +pub fn clone_slim_100_and_drain_all(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| src.clone().drain_filter(|_, _| true).count()) +} + +#[bench] +pub fn clone_slim_100_and_drain_half(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| { + let mut map = src.clone(); + assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 100 / 2); + assert_eq!(map.len(), 100 / 2); + }) +} + +#[bench] +pub fn clone_slim_100_and_into_iter(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| src.clone().into_iter().count()) +} + +#[bench] +pub fn clone_slim_100_and_pop_all(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| { + let mut map = src.clone(); + while map.pop_first().is_some() {} + map + }); +} + +#[bench] +pub fn clone_slim_100_and_remove_all(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| { + let mut map = src.clone(); + while let Some(elt) = map.iter().map(|(&i, _)| i).next() { + let v = map.remove(&elt); + debug_assert!(v.is_some()); + } + map + }); +} + +#[bench] +pub fn clone_slim_100_and_remove_half(b: &mut Bencher) { + let src = slim_map(100); + b.iter(|| { + let mut map = src.clone(); + for i in (0..100).step_by(2) { + let v = map.remove(&i); + debug_assert!(v.is_some()); + } + assert_eq!(map.len(), 100 / 2); + map + }) +} + +#[bench] +pub fn clone_slim_10k(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| src.clone()) +} + +#[bench] +pub fn clone_slim_10k_and_clear(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| src.clone().clear()) +} + +#[bench] +pub fn clone_slim_10k_and_drain_all(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| src.clone().drain_filter(|_, _| true).count()) +} + +#[bench] +pub fn clone_slim_10k_and_drain_half(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| { + let mut map = src.clone(); + assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 10_000 / 2); + assert_eq!(map.len(), 10_000 / 2); + }) +} + +#[bench] +pub fn clone_slim_10k_and_into_iter(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| src.clone().into_iter().count()) +} + +#[bench] +pub fn clone_slim_10k_and_pop_all(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| { + let mut map = src.clone(); + while map.pop_first().is_some() {} + map + }); +} + +#[bench] +pub fn clone_slim_10k_and_remove_all(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| { + let mut map = src.clone(); + while let Some(elt) = map.iter().map(|(&i, _)| i).next() { + let v = map.remove(&elt); + debug_assert!(v.is_some()); + } + map + }); +} + +#[bench] +pub fn clone_slim_10k_and_remove_half(b: &mut Bencher) { + let src = slim_map(10_000); + b.iter(|| { + let mut map = src.clone(); + for i in (0..10_000).step_by(2) { + let v = map.remove(&i); + debug_assert!(v.is_some()); + } + assert_eq!(map.len(), 10_000 / 2); + map + }) +} + +#[bench] +pub fn clone_fat_val_100(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| src.clone()) +} + +#[bench] +pub fn clone_fat_val_100_and_clear(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| src.clone().clear()) +} + +#[bench] +pub fn clone_fat_val_100_and_drain_all(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| src.clone().drain_filter(|_, _| true).count()) +} + +#[bench] +pub fn clone_fat_val_100_and_drain_half(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| { + let mut map = src.clone(); + assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 100 / 2); + assert_eq!(map.len(), 100 / 2); + }) +} + +#[bench] +pub fn clone_fat_val_100_and_into_iter(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| src.clone().into_iter().count()) +} + +#[bench] +pub fn clone_fat_val_100_and_pop_all(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| { + let mut map = src.clone(); + while map.pop_first().is_some() {} + map + }); +} + +#[bench] +pub fn clone_fat_val_100_and_remove_all(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| { + let mut map = src.clone(); + while let Some(elt) = map.iter().map(|(&i, _)| i).next() { + let v = map.remove(&elt); + debug_assert!(v.is_some()); + } + map + }); +} + +#[bench] +pub fn clone_fat_val_100_and_remove_half(b: &mut Bencher) { + let src = fat_val_map(100); + b.iter(|| { + let mut map = src.clone(); + for i in (0..100).step_by(2) { + let v = map.remove(&i); + debug_assert!(v.is_some()); + } + assert_eq!(map.len(), 100 / 2); + map + }) +} + +#[bench] +pub fn clone_fat_100(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| src.clone()) +} + +#[bench] +pub fn clone_fat_100_and_clear(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| src.clone().clear()) +} + +#[bench] +pub fn clone_fat_100_and_drain_all(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| src.clone().drain_filter(|_, _| true).count()) +} + +#[bench] +pub fn clone_fat_100_and_drain_half(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| { + let mut map = src.clone(); + assert_eq!(map.drain_filter(|i, _| i[0] % 2 == 0).count(), 100 / 2); + assert_eq!(map.len(), 100 / 2); + }) +} + +#[bench] +pub fn clone_fat_100_and_into_iter(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| src.clone().into_iter().count()) +} + +#[bench] +pub fn clone_fat_100_and_pop_all(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| { + let mut map = src.clone(); + while map.pop_first().is_some() {} + map + }); +} + +#[bench] +pub fn clone_fat_100_and_remove_all(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| { + let mut map = src.clone(); + while let Some(elt) = map.iter().map(|(&i, _)| i).next() { + let v = map.remove(&elt); + debug_assert!(v.is_some()); + } + map + }); +} + +#[bench] +pub fn clone_fat_100_and_remove_half(b: &mut Bencher) { + let src = fat_map(100); + b.iter(|| { + let mut map = src.clone(); + for i in (0..100).step_by(2) { + let v = map.remove(&[i; FAT]); + debug_assert!(v.is_some()); + } + assert_eq!(map.len(), 100 / 2); + map + }) +} diff --git a/library/alloc/benches/btree/set.rs b/library/alloc/benches/btree/set.rs index 2518506b9b5f3..07bf5093727c0 100644 --- a/library/alloc/benches/btree/set.rs +++ b/library/alloc/benches/btree/set.rs @@ -50,27 +50,31 @@ macro_rules! set_bench { }; } +fn slim_set(n: usize) -> BTreeSet { + (0..n).collect::>() +} + #[bench] pub fn clone_100(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| src.clone()) } #[bench] pub fn clone_100_and_clear(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| src.clone().clear()) } #[bench] pub fn clone_100_and_drain_all(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| src.clone().drain_filter(|_| true).count()) } #[bench] pub fn clone_100_and_drain_half(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| { let mut set = src.clone(); assert_eq!(set.drain_filter(|i| i % 2 == 0).count(), 100 / 2); @@ -80,13 +84,13 @@ pub fn clone_100_and_drain_half(b: &mut Bencher) { #[bench] pub fn clone_100_and_into_iter(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| src.clone().into_iter().count()) } #[bench] pub fn clone_100_and_pop_all(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| { let mut set = src.clone(); while set.pop_first().is_some() {} @@ -96,11 +100,12 @@ pub fn clone_100_and_pop_all(b: &mut Bencher) { #[bench] pub fn clone_100_and_remove_all(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| { let mut set = src.clone(); while let Some(elt) = set.iter().copied().next() { - set.remove(&elt); + let ok = set.remove(&elt); + debug_assert!(ok); } set }); @@ -108,11 +113,12 @@ pub fn clone_100_and_remove_all(b: &mut Bencher) { #[bench] pub fn clone_100_and_remove_half(b: &mut Bencher) { - let src = pos(100); + let src = slim_set(100); b.iter(|| { let mut set = src.clone(); - for i in (2..=100 as i32).step_by(2) { - set.remove(&i); + for i in (0..100).step_by(2) { + let ok = set.remove(&i); + debug_assert!(ok); } assert_eq!(set.len(), 100 / 2); set @@ -121,25 +127,25 @@ pub fn clone_100_and_remove_half(b: &mut Bencher) { #[bench] pub fn clone_10k(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| src.clone()) } #[bench] pub fn clone_10k_and_clear(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| src.clone().clear()) } #[bench] pub fn clone_10k_and_drain_all(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| src.clone().drain_filter(|_| true).count()) } #[bench] pub fn clone_10k_and_drain_half(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| { let mut set = src.clone(); assert_eq!(set.drain_filter(|i| i % 2 == 0).count(), 10_000 / 2); @@ -149,13 +155,13 @@ pub fn clone_10k_and_drain_half(b: &mut Bencher) { #[bench] pub fn clone_10k_and_into_iter(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| src.clone().into_iter().count()) } #[bench] pub fn clone_10k_and_pop_all(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| { let mut set = src.clone(); while set.pop_first().is_some() {} @@ -165,11 +171,12 @@ pub fn clone_10k_and_pop_all(b: &mut Bencher) { #[bench] pub fn clone_10k_and_remove_all(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| { let mut set = src.clone(); while let Some(elt) = set.iter().copied().next() { - set.remove(&elt); + let ok = set.remove(&elt); + debug_assert!(ok); } set }); @@ -177,11 +184,12 @@ pub fn clone_10k_and_remove_all(b: &mut Bencher) { #[bench] pub fn clone_10k_and_remove_half(b: &mut Bencher) { - let src = pos(10_000); + let src = slim_set(10_000); b.iter(|| { let mut set = src.clone(); - for i in (2..=10_000 as i32).step_by(2) { - set.remove(&i); + for i in (0..10_000).step_by(2) { + let ok = set.remove(&i); + debug_assert!(ok); } assert_eq!(set.len(), 10_000 / 2); set From 99398dd2fd46c24857707ee5db8c7a90f0811850 Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Tue, 14 Jul 2020 11:32:50 +0200 Subject: [PATCH 08/15] BTreeMap::drain_filter no longer touches the root during iteration --- library/alloc/src/collections/btree/map.rs | 87 +++++++++++++++------ library/alloc/src/collections/btree/node.rs | 16 ++-- 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 24d1f61fa68c4..6184051316ef8 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -174,7 +174,7 @@ impl Clone for BTreeMap { { let out_root = BTreeMap::ensure_is_owned(&mut out_tree.root); - let mut out_node = out_root.push_level(); + let mut out_node = out_root.push_internal_level(); let mut in_edge = internal.first_edge(); while let Ok(kv) = in_edge.right_kv() { let (k, v) = kv.into_kv(); @@ -1080,9 +1080,9 @@ impl BTreeMap { test_node = parent.forget_type(); } } - Err(node) => { + Err(_) => { // We are at the top, create a new root node and push there. - open_node = node.into_root_mut().push_level(); + open_node = root.push_internal_level(); break; } } @@ -1092,7 +1092,7 @@ impl BTreeMap { let tree_height = open_node.height() - 1; let mut right_tree = node::Root::new_leaf(); for _ in 0..tree_height { - right_tree.push_level(); + right_tree.push_internal_level(); } open_node.push(key, value, right_tree); @@ -1171,7 +1171,7 @@ impl BTreeMap { let mut right = Self::new(); let right_root = Self::ensure_is_owned(&mut right.root); for _ in 0..left_root.height() { - right_root.push_level(); + right_root.push_internal_level(); } { @@ -1255,7 +1255,11 @@ impl BTreeMap { } pub(super) fn drain_filter_inner(&mut self) -> DrainFilterInner<'_, K, V> { let front = self.root.as_mut().map(|r| r.as_mut().first_leaf_edge()); - DrainFilterInner { length: &mut self.length, cur_leaf_edge: front } + DrainFilterInner { + length: &mut self.length, + cur_leaf_edge: front, + emptied_internal_root: false, + } } /// Calculates the number of elements if it is incorrect. @@ -1625,6 +1629,7 @@ where pub(super) struct DrainFilterInner<'a, K: 'a, V: 'a> { length: &'a mut usize, cur_leaf_edge: Option, K, V, marker::Leaf>, marker::Edge>>, + emptied_internal_root: bool, } #[unstable(feature = "btree_drain_filter", issue = "70530")] @@ -1665,6 +1670,17 @@ where } } +impl Drop for DrainFilterInner<'_, K, V> { + fn drop(&mut self) { + if self.emptied_internal_root { + if let Some(handle) = self.cur_leaf_edge.take() { + let root = handle.into_node().into_root_mut(); + root.pop_internal_level(); + } + } + } +} + impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> { /// Allow Debug implementations to predict the next element. pub(super) fn peek(&self) -> Option<(&K, &V)> { @@ -1681,9 +1697,10 @@ impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> { let (k, v) = kv.kv_mut(); if pred(k, v) { *self.length -= 1; - let (k, v, leaf_edge_location) = kv.remove_kv_tracking(); - self.cur_leaf_edge = Some(leaf_edge_location); - return Some((k, v)); + let RemoveResult { old_kv, pos, emptied_internal_root } = kv.remove_kv_tracking(); + self.cur_leaf_edge = Some(pos); + self.emptied_internal_root |= emptied_internal_root; + return Some(old_kv); } self.cur_leaf_edge = Some(kv.next_leaf_edge()); } @@ -2477,7 +2494,7 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> { } }, Err(root) => { - root.push_level().push(ins_k, ins_v, ins_edge); + root.push_internal_level().push(ins_k, ins_v, ins_edge); return unsafe { &mut *out_ptr }; } } @@ -2647,20 +2664,35 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> { self.remove_kv().1 } + // Body of `remove_entry`, separate to keep the above implementations short. fn remove_kv(self) -> (K, V) { *self.length -= 1; - let (old_key, old_val, _) = self.handle.remove_kv_tracking(); - (old_key, old_val) + let RemoveResult { old_kv, pos, emptied_internal_root } = self.handle.remove_kv_tracking(); + let root = pos.into_node().into_root_mut(); + if emptied_internal_root { + root.pop_internal_level(); + } + old_kv } } +struct RemoveResult<'a, K, V> { + // Key and value removed. + old_kv: (K, V), + // Unique location at the leaf level that the removed KV lopgically collapsed into. + pos: Handle, K, V, marker::Leaf>, marker::Edge>, + // Whether the remove left behind and empty internal root node, that should be removed + // using `pop_internal_level`. + emptied_internal_root: bool, +} + impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInternal>, marker::KV> { - /// Removes a key/value-pair from the map, and returns that pair, as well as - /// the leaf edge corresponding to that former pair. - fn remove_kv_tracking( - self, - ) -> (K, V, Handle, K, V, marker::Leaf>, marker::Edge>) { + /// Removes a key/value-pair from the tree, and returns that pair, as well as + /// the leaf edge corresponding to that former pair. It's possible this leaves + /// an empty internal root node, which the caller should subsequently pop from + /// the map holding the tree. The caller should also decrement the map's length. + fn remove_kv_tracking(self) -> RemoveResult<'a, K, V> { let (mut pos, old_key, old_val, was_internal) = match self.force() { Leaf(leaf) => { let (hole, old_key, old_val) = leaf.remove(); @@ -2689,6 +2721,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInter }; // Handle underflow + let mut emptied_internal_root = false; let mut cur_node = unsafe { ptr::read(&pos).into_node().forget_type() }; let mut at_leaf = true; while cur_node.len() < node::MIN_LEN { @@ -2709,8 +2742,8 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInter let parent = edge.into_node(); if parent.len() == 0 { - // We must be at the root - parent.into_root_mut().pop_level(); + // This empty parent must be the root, and should be popped off the tree. + emptied_internal_root = true; break; } else { cur_node = parent.forget_type(); @@ -2737,7 +2770,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInter pos = unsafe { unwrap_unchecked(pos.next_kv().ok()).next_leaf_edge() }; } - (old_key, old_val, pos) + RemoveResult { old_kv: (old_key, old_val), pos, emptied_internal_root } } } @@ -2745,7 +2778,7 @@ impl node::Root { /// Removes empty levels on the top, but keep an empty leaf if the entire tree is empty. fn fix_top(&mut self) { while self.height() > 0 && self.as_ref().len() == 0 { - self.pop_level(); + self.pop_internal_level(); } } @@ -2817,8 +2850,16 @@ fn handle_underfull_node( let (is_left, mut handle) = match parent.left_kv() { Ok(left) => (true, left), Err(parent) => { - let right = unsafe { unwrap_unchecked(parent.right_kv().ok()) }; - (false, right) + match parent.right_kv() { + Ok(right) => (false, right), + Err(_) => { + // The underfull node has an empty parent, so it is the only child + // of an empty root. It is destined to become the new root, thus + // allowed to be underfull. The empty parent should be removed later + // by `pop_internal_level`. + return AtRoot; + } + } } }; diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index f7bd64608d63c..4a7497a983297 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -191,8 +191,9 @@ impl Root { } /// Adds a new internal node with a single edge, pointing to the previous root, and make that - /// new node the root. This increases the height by 1 and is the opposite of `pop_level`. - pub fn push_level(&mut self) -> NodeRef, K, V, marker::Internal> { + /// new node the root. This increases the height by 1 and is the opposite of + /// `pop_internal_level`. + pub fn push_internal_level(&mut self) -> NodeRef, K, V, marker::Internal> { let mut new_node = Box::new(unsafe { InternalNode::new() }); new_node.edges[0].write(unsafe { BoxedNode::from_ptr(self.node.as_ptr()) }); @@ -213,11 +214,12 @@ impl Root { ret } - /// Removes the root node, using its first child as the new root. This cannot be called when - /// the tree consists only of a leaf node. As it is intended only to be called when the root - /// has only one edge, no cleanup is done on any of the other children of the root. - /// This decreases the height by 1 and is the opposite of `push_level`. - pub fn pop_level(&mut self) { + /// Removes the internal root node, using its first child as the new root. + /// As it is intended only to be called when the root has only one child, + /// no cleanup is done on any of the other children of the root. + /// This decreases the height by 1 and is the opposite of `push_internal_level`. + /// Panics if there is no internal level, i.e. if the root is a leaf. + pub fn pop_internal_level(&mut self) { assert!(self.height > 0); let top = self.node.ptr; From 70ba491b7823c17887c6e29184f5af3f725578a3 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 1 Aug 2020 10:11:15 -0400 Subject: [PATCH 09/15] Update elasticlunr-rs and ammonia transitive deps This removes all dependencies on pre-1.0 proc-macro ecosystem crates (syn, quote, and proc-macro2) --- Cargo.lock | 355 +++++++++++++++---------------------- src/tools/tidy/src/deps.rs | 1 - 2 files changed, 140 insertions(+), 216 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e90b7e6fba1c..9832053d37e6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,19 +37,20 @@ version = "0.0.0" dependencies = [ "compiler_builtins", "core", - "rand 0.7.3", - "rand_xorshift 0.2.0", + "rand", + "rand_xorshift", ] [[package]] name = "ammonia" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e266e1f4be5ffa05309f650e2586fe1d3ae6034eb24025a7ae1dfecc330823a" +checksum = "89eac85170f4b3fb3dc5e442c1cfb036cb8eecf9dbbd431a161ffad15d90ea3b" dependencies = [ "html5ever", "lazy_static", "maplit", + "markup5ever_rcdom", "matches", "tendril", "url 2.1.0", @@ -343,7 +344,7 @@ dependencies = [ "termcolor", "toml", "unicode-width", - "unicode-xid 0.2.0", + "unicode-xid", "url 2.1.0", "walkdir", "winapi 0.3.8", @@ -444,9 +445,9 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d463e01905d607e181de72e8608721d3269f29176c9a14ce037011316ae7131d" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", "synstructure", ] @@ -547,12 +548,12 @@ dependencies = [ "lazy_static", "pulldown-cmark", "quine-mc_cluskey", - "quote 1.0.2", + "quote", "regex-syntax", "semver 0.9.0", "serde", "smallvec 1.4.0", - "syn 1.0.11", + "syn", "toml", "unicode-normalization", "url 2.1.0", @@ -667,7 +668,7 @@ checksum = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" name = "core" version = "0.0.0" dependencies = [ - "rand 0.7.3", + "rand", ] [[package]] @@ -788,8 +789,8 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47c5e5ac752e18207b12e16b10631ae5f7f68f8805f335f9b817ead83d9ffce1" dependencies = [ - "quote 1.0.2", - "syn 1.0.11", + "quote", + "syn", ] [[package]] @@ -835,9 +836,9 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -846,9 +847,9 @@ version = "0.99.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2159be042979966de68315bce7034bb000c775f22e3e834e1c52ff78f041cae8" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -923,9 +924,9 @@ checksum = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" [[package]] name = "elasticlunr-rs" -version = "2.3.4" +version = "2.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99a310cd1f9770e7bf8e48810c7bcbb0e078c8fb23a8c7bcf0da4c2bf61a455" +checksum = "35622eb004c8f0c5e7e2032815f3314a93df0db30a1ce5c94e62c1ecc81e22b9" dependencies = [ "lazy_static", "regex", @@ -1003,9 +1004,9 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", "synstructure", ] @@ -1298,16 +1299,16 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.24.1" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "025483b0a1e4577bb28578318c886ee5f817dda6eb62473269349044406644cb" +checksum = "aafcf38a1a36118242d29b92e1b08ef84e67e4a5ed06e0a80be20e6a32bfed6b" dependencies = [ "log", "mac", "markup5ever", - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1515,9 +1516,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8609af8f63b626e8e211f52441fcdb6ec54f1a446606b10d5c89ae9bf8a20058" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1735,9 +1736,9 @@ checksum = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" [[package]] name = "markup5ever" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65381d9d47506b8592b97c4efd936afcf673b09b059f2bef39c7211ee78b9d03" +checksum = "aae38d669396ca9b707bfc3db254bc382ddb94f57cc5c235f34623a669a01dab" dependencies = [ "log", "phf", @@ -1750,6 +1751,18 @@ dependencies = [ "tendril", ] +[[package]] +name = "markup5ever_rcdom" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f015da43bcd8d4f144559a3423f4591d69b8ce0652c905374da7205df336ae2b" +dependencies = [ + "html5ever", + "markup5ever", + "tendril", + "xml5ever", +] + [[package]] name = "matchers" version = "0.0.1" @@ -1937,7 +1950,7 @@ dependencies = [ "hex 0.4.0", "libc", "log", - "rand 0.7.3", + "rand", "rustc-workspace-hack", "rustc_version", "shell-escape", @@ -2131,7 +2144,7 @@ dependencies = [ "log", "mio-named-pipes", "miow 0.3.3", - "rand 0.7.3", + "rand", "tokio", "tokio-named-pipes", "tokio-uds", @@ -2233,9 +2246,9 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2261,18 +2274,18 @@ dependencies = [ [[package]] name = "phf" -version = "0.7.24" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" +checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ "phf_shared", ] [[package]] name = "phf_codegen" -version = "0.7.24" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" +checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" dependencies = [ "phf_generator", "phf_shared", @@ -2280,19 +2293,19 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.7.24" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ "phf_shared", - "rand 0.6.1", + "rand", ] [[package]] name = "phf_shared" -version = "0.7.24" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" dependencies = [ "siphasher", ] @@ -2363,18 +2376,9 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2383,7 +2387,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" dependencies = [ - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -2441,22 +2445,13 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" -[[package]] -name = "quote" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" dependencies = [ - "proc-macro2 1.0.3", + "proc-macro2", ] [[package]] @@ -2482,25 +2477,6 @@ dependencies = [ "rustc-ap-rustc_span", ] -[[package]] -name = "rand" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a" -dependencies = [ - "cloudabi", - "fuchsia-zircon", - "libc", - "rand_chacha 0.1.0", - "rand_core 0.3.0", - "rand_hc 0.1.0", - "rand_isaac", - "rand_pcg", - "rand_xorshift 0.1.0", - "rustc_version", - "winapi 0.3.8", -] - [[package]] name = "rand" version = "0.7.3" @@ -2509,19 +2485,10 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha 0.2.2", + "rand_chacha", "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a" -dependencies = [ - "rand_core 0.3.0", - "rustc_version", + "rand_hc", + "rand_pcg", ] [[package]] @@ -2555,15 +2522,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.0", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -2573,15 +2531,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.0", -] - [[package]] name = "rand_os" version = "0.1.3" @@ -2598,21 +2547,11 @@ dependencies = [ [[package]] name = "rand_pcg" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" -dependencies = [ - "rand_core 0.3.0", - "rustc_version", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "rand_core 0.3.0", + "rand_core 0.5.1", ] [[package]] @@ -2752,7 +2691,7 @@ dependencies = [ "num_cpus", "ordslice", "racer", - "rand 0.7.3", + "rand", "rayon", "regex", "rls-analysis", @@ -2824,7 +2763,7 @@ dependencies = [ "env_logger 0.7.1", "futures", "log", - "rand 0.7.3", + "rand", "rls-data", "rls-ipc", "serde", @@ -3051,7 +2990,7 @@ version = "669.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456af5f09c006cf6c22c1a433ee0232c4bb74bdc6c647a010166a47c94ed2a63" dependencies = [ - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -3060,9 +2999,9 @@ version = "669.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64f6acd192f313047759a346b892998b626466b93fe04f415da5f38906bb3b4c" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", "synstructure", ] @@ -3224,13 +3163,13 @@ name = "rustc-workspace-hack" version = "1.0.0" dependencies = [ "crossbeam-utils 0.7.2", - "proc-macro2 1.0.3", - "quote 1.0.2", + "proc-macro2", + "quote", "serde", "serde_json", "smallvec 0.6.10", "smallvec 1.4.0", - "syn 1.0.11", + "syn", "url 2.1.0", "winapi 0.3.8", ] @@ -3555,7 +3494,7 @@ dependencies = [ name = "rustc_incremental" version = "0.0.0" dependencies = [ - "rand 0.7.3", + "rand", "rustc_ast", "rustc_data_structures", "rustc_fs_util", @@ -3644,7 +3583,7 @@ dependencies = [ name = "rustc_lexer" version = "0.1.0" dependencies = [ - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -3681,9 +3620,9 @@ dependencies = [ name = "rustc_macros" version = "0.1.0" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", "synstructure", ] @@ -4134,10 +4073,10 @@ dependencies = [ name = "rustfmt-config_proc_macro" version = "0.2.0" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", + "proc-macro2", + "quote", "serde", - "syn 1.0.11", + "syn", ] [[package]] @@ -4264,9 +4203,9 @@ version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -4295,9 +4234,9 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd02c7587ec314570041b2754829f84d873ced14a96d1fd1823531e11db40573" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -4345,9 +4284,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.2.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" +checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" [[package]] name = "sized-chunks" @@ -4427,7 +4366,7 @@ dependencies = [ "panic_abort", "panic_unwind", "profiler_builtins", - "rand 0.7.3", + "rand", "rustc-demangle", "unwind", "wasi", @@ -4435,38 +4374,29 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423" +checksum = "2940c75beb4e3bf3a494cef919a747a2cb81e52571e212bfbd185074add7208a" dependencies = [ "lazy_static", "new_debug_unreachable", "phf_shared", "precomputed-hash", "serde", - "string_cache_codegen", - "string_cache_shared", ] [[package]] name = "string_cache_codegen" -version = "0.4.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da" +checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97" dependencies = [ "phf_generator", "phf_shared", - "proc-macro2 0.4.30", - "quote 0.6.12", - "string_cache_shared", + "proc-macro2", + "quote", ] -[[package]] -name = "string_cache_shared" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" - [[package]] name = "strip-ansi-escapes" version = "0.1.0" @@ -4500,38 +4430,27 @@ checksum = "2ae9e5165d463a0dea76967d021f8d0f9316057bf5163aa2a4843790e842ff37" dependencies = [ "heck", "proc-macro-error", - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "strum" -version = "0.11.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6c3a2071519ab6a48f465808c4c1ffdd00dfc8e93111d02b4fc5abab177676e" +checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b" [[package]] name = "strum_macros" -version = "0.11.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8baacebd7b7c9b864d83a6ba7a246232983e277b86fa5cdec77f565715a4b136" +checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" dependencies = [ "heck", - "proc-macro2 0.4.30", - "quote 0.6.12", - "syn 0.15.35", -] - -[[package]] -name = "syn" -version = "0.15.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.12", - "unicode-xid 0.1.0", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -4540,9 +4459,9 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -4551,10 +4470,10 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "syn", + "unicode-xid", ] [[package]] @@ -4577,7 +4496,7 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ "cfg-if", "libc", - "rand 0.7.3", + "rand", "redox_syscall", "remove_dir_all", "winapi 0.3.8", @@ -4682,9 +4601,9 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24069c0ba08aab54289d6a25f5036d94afc61e1538bbc42ae5501df141c9027d" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -4983,9 +4902,9 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" dependencies = [ - "proc-macro2 1.0.3", - "quote 1.0.2", - "syn 1.0.11", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -5102,12 +5021,6 @@ dependencies = [ "rustc-std-workspace-std", ] -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.0" @@ -5295,6 +5208,18 @@ dependencies = [ "libc", ] +[[package]] +name = "xml5ever" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1b52e6e8614d4a58b8e70cf51ec0cc21b256ad8206708bcff8139b5bbd6a59" +dependencies = [ + "log", + "mac", + "markup5ever", + "time", +] + [[package]] name = "xz2" version = "0.1.5" diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 55e17466a881e..1f988f7d81b72 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -138,7 +138,6 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "rand_chacha", "rand_core", "rand_hc", - "rand_isaac", "rand_pcg", "rand_xorshift", "redox_syscall", From 980edf5baa0c6563c75aa95332a12c77e68dd29e Mon Sep 17 00:00:00 2001 From: bishtpawan Date: Sun, 2 Aug 2020 12:21:39 +0530 Subject: [PATCH 10/15] Replace from log to tracing in libsrustrustc_ast_lowering, librustc_ast_passes, librustc_ast_pretty --- src/librustc_ast_lowering/Cargo.toml | 2 +- src/librustc_ast_lowering/item.rs | 2 +- src/librustc_ast_lowering/lib.rs | 2 +- src/librustc_ast_lowering/path.rs | 2 +- src/librustc_ast_passes/Cargo.toml | 2 +- src/librustc_ast_passes/feature_gate.rs | 2 +- src/librustc_ast_pretty/Cargo.toml | 2 +- src/librustc_ast_pretty/pp.rs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/librustc_ast_lowering/Cargo.toml b/src/librustc_ast_lowering/Cargo.toml index 51f34a1b78e97..bf7e69a31abcb 100644 --- a/src/librustc_ast_lowering/Cargo.toml +++ b/src/librustc_ast_lowering/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_arena = { path = "../librustc_arena" } -log = { package = "tracing", version = "0.1" } +tracing = "0.1" rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_hir = { path = "../librustc_hir" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index dd5e658102fac..3e8565091e58c 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -17,7 +17,7 @@ use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::Span; use rustc_target::spec::abi; -use log::debug; +use tracing::debug; use smallvec::{smallvec, SmallVec}; use std::collections::BTreeSet; diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 1c70eef3bf5e3..da36bd8581329 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -64,7 +64,7 @@ use rustc_span::source_map::{respan, DesugaringKind, ExpnData, ExpnKind}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; -use log::{debug, trace}; +use tracing::{debug, trace}; use smallvec::{smallvec, SmallVec}; use std::collections::BTreeMap; use std::mem; diff --git a/src/librustc_ast_lowering/path.rs b/src/librustc_ast_lowering/path.rs index e5ce51f8d2d1f..0e13ee7ed3933 100644 --- a/src/librustc_ast_lowering/path.rs +++ b/src/librustc_ast_lowering/path.rs @@ -12,7 +12,7 @@ use rustc_session::lint::BuiltinLintDiagnostics; use rustc_span::symbol::Ident; use rustc_span::Span; -use log::debug; +use tracing::debug; use smallvec::smallvec; impl<'a, 'hir> LoweringContext<'a, 'hir> { diff --git a/src/librustc_ast_passes/Cargo.toml b/src/librustc_ast_passes/Cargo.toml index c53089a4afc5c..6db9bce3164bb 100644 --- a/src/librustc_ast_passes/Cargo.toml +++ b/src/librustc_ast_passes/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" [dependencies] itertools = "0.8" -log = { package = "tracing", version = "0.1" } +tracing = "0.1" rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_ast_passes/feature_gate.rs b/src/librustc_ast_passes/feature_gate.rs index b424c8afb3471..2fe208c3ce68c 100644 --- a/src/librustc_ast_passes/feature_gate.rs +++ b/src/librustc_ast_passes/feature_gate.rs @@ -10,7 +10,7 @@ use rustc_span::source_map::Spanned; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; -use log::debug; +use tracing::debug; macro_rules! gate_feature_fn { ($cx: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr) => {{ diff --git a/src/librustc_ast_pretty/Cargo.toml b/src/librustc_ast_pretty/Cargo.toml index 4035346d35446..d26205c791dc0 100644 --- a/src/librustc_ast_pretty/Cargo.toml +++ b/src/librustc_ast_pretty/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -log = { package = "tracing", version = "0.1" } +tracing = "0.1" rustc_span = { path = "../librustc_span" } rustc_ast = { path = "../librustc_ast" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_ast_pretty/pp.rs b/src/librustc_ast_pretty/pp.rs index 4bb806a923e6c..9729c3ad48c86 100644 --- a/src/librustc_ast_pretty/pp.rs +++ b/src/librustc_ast_pretty/pp.rs @@ -132,7 +132,7 @@ //! methods called `Printer::scan_*`, and the 'PRINT' process is the //! method called `Printer::print`. -use log::debug; +use tracing::debug; use std::borrow::Cow; use std::collections::VecDeque; use std::fmt; From fee58ebe20ed6e920afaa8414425e7d04f9dd8ea Mon Sep 17 00:00:00 2001 From: bishtpawan Date: Sun, 2 Aug 2020 13:24:08 +0530 Subject: [PATCH 11/15] Replace from log to tracing --- src/librustc_ast_lowering/item.rs | 2 +- src/librustc_ast_lowering/lib.rs | 2 +- src/librustc_ast_lowering/path.rs | 2 +- src/librustc_ast_pretty/pp.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index 3e8565091e58c..5414e58429047 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -17,9 +17,9 @@ use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::Span; use rustc_target::spec::abi; -use tracing::debug; use smallvec::{smallvec, SmallVec}; use std::collections::BTreeSet; +use tracing::debug; pub(super) struct ItemLowerer<'a, 'lowering, 'hir> { pub(super) lctx: &'a mut LoweringContext<'lowering, 'hir>, diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index da36bd8581329..9df7ad2a9acf4 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -64,10 +64,10 @@ use rustc_span::source_map::{respan, DesugaringKind, ExpnData, ExpnKind}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; -use tracing::{debug, trace}; use smallvec::{smallvec, SmallVec}; use std::collections::BTreeMap; use std::mem; +use tracing::{debug, trace}; macro_rules! arena_vec { ($this:expr; $($x:expr),*) => ({ diff --git a/src/librustc_ast_lowering/path.rs b/src/librustc_ast_lowering/path.rs index 0e13ee7ed3933..2541d6824fec4 100644 --- a/src/librustc_ast_lowering/path.rs +++ b/src/librustc_ast_lowering/path.rs @@ -12,8 +12,8 @@ use rustc_session::lint::BuiltinLintDiagnostics; use rustc_span::symbol::Ident; use rustc_span::Span; -use tracing::debug; use smallvec::smallvec; +use tracing::debug; impl<'a, 'hir> LoweringContext<'a, 'hir> { crate fn lower_qpath( diff --git a/src/librustc_ast_pretty/pp.rs b/src/librustc_ast_pretty/pp.rs index 9729c3ad48c86..ca7f127ced60d 100644 --- a/src/librustc_ast_pretty/pp.rs +++ b/src/librustc_ast_pretty/pp.rs @@ -132,10 +132,10 @@ //! methods called `Printer::scan_*`, and the 'PRINT' process is the //! method called `Printer::print`. -use tracing::debug; use std::borrow::Cow; use std::collections::VecDeque; use std::fmt; +use tracing::debug; /// How to break. Described in more detail in the module docs. #[derive(Clone, Copy, PartialEq)] From 507f403f952501d9c2c819c5306c0ee4af3183bd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 26 Jul 2020 17:38:47 +0200 Subject: [PATCH 12/15] Clean up E0733 explanation --- src/librustc_error_codes/error_codes/E0733.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0733.md b/src/librustc_error_codes/error_codes/E0733.md index 0bda7a7d68283..051b75148e509 100644 --- a/src/librustc_error_codes/error_codes/E0733.md +++ b/src/librustc_error_codes/error_codes/E0733.md @@ -1,4 +1,6 @@ -Recursion in an `async fn` requires boxing. For example, this will not compile: +An [`async`] function used recursion without boxing. + +Erroneous code example: ```edition2018,compile_fail,E0733 async fn foo(n: usize) { @@ -8,8 +10,8 @@ async fn foo(n: usize) { } ``` -To achieve async recursion, the `async fn` needs to be desugared -such that the `Future` is explicit in the return type: +To perform async recursion, the `async fn` needs to be desugared such that the +`Future` is explicit in the return type: ```edition2018,compile_fail,E0720 use std::future::Future; @@ -36,5 +38,7 @@ fn foo_recursive(n: usize) -> Pin>> { } ``` -The `Box<...>` ensures that the result is of known size, -and the pin is required to keep it in the same place in memory. +The `Box<...>` ensures that the result is of known size, and the pin is +required to keep it in the same place in memory. + +[`async`]: https://doc.rust-lang.org/std/keyword.async.html From 093e45dce656780f0ba4f3c530541def23f9d332 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Aug 2020 13:26:02 +0200 Subject: [PATCH 13/15] Clean up E0744 explanation --- src/librustc_error_codes/error_codes/E0744.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0744.md b/src/librustc_error_codes/error_codes/E0744.md index 56b947a8282ed..14cff3613e023 100644 --- a/src/librustc_error_codes/error_codes/E0744.md +++ b/src/librustc_error_codes/error_codes/E0744.md @@ -1,7 +1,6 @@ -Control-flow expressions are not allowed inside a const context. +A control-flow expression was used inside a const context. -At the moment, `if` and `match`, as well as the looping constructs `for`, -`while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`. +Erroneous code example: ```compile_fail,E0744 const _: i32 = { @@ -13,6 +12,9 @@ const _: i32 = { }; ``` +At the moment, `if` and `match`, as well as the looping constructs `for`, +`while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`. + This will be allowed at some point in the future, but the implementation is not yet complete. See the tracking issue for [conditionals] or [loops] in a const context for the current status. From 4d4b8f2d4179cf29089c58e0d9a81c8945af4f4a Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 2 Aug 2020 14:24:22 +0200 Subject: [PATCH 14/15] Rename rustc_middle::cstore::DepKind to DependencyKind. --- src/librustc_metadata/creader.rs | 30 +++++++++++----------- src/librustc_metadata/dependency_format.rs | 6 ++--- src/librustc_metadata/rmeta/decoder.rs | 8 +++--- src/librustc_metadata/rmeta/mod.rs | 4 +-- src/librustc_middle/middle/cstore.rs | 8 +++--- src/librustc_middle/query/mod.rs | 2 +- src/librustc_middle/ty/query/mod.rs | 12 ++++----- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 724b4123fab6c..05a8c010d0cd0 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -13,7 +13,7 @@ use rustc_expand::base::SyntaxExtension; use rustc_hir::def_id::{CrateNum, LocalDefId, LOCAL_CRATE}; use rustc_hir::definitions::Definitions; use rustc_index::vec::IndexVec; -use rustc_middle::middle::cstore::{CrateSource, DepKind, ExternCrate}; +use rustc_middle::middle::cstore::{CrateDepKind, CrateSource, ExternCrate}; use rustc_middle::middle::cstore::{ExternCrateSource, MetadataLoaderDyn}; use rustc_middle::ty::TyCtxt; use rustc_session::config::{self, CrateType, ExternLocation}; @@ -294,7 +294,7 @@ impl<'a> CrateLoader<'a> { host_lib: Option, root: Option<&CratePaths>, lib: Library, - dep_kind: DepKind, + dep_kind: CrateDepKind, name: Symbol, ) -> Result { let _prof_timer = self.sess.prof.generic_activity("metadata_register_crate"); @@ -425,7 +425,7 @@ impl<'a> CrateLoader<'a> { &'b mut self, name: Symbol, span: Span, - dep_kind: DepKind, + dep_kind: CrateDepKind, dep: Option<(&'b CratePaths, &'b CrateDep)>, ) -> CrateNum { if dep.is_none() { @@ -438,7 +438,7 @@ impl<'a> CrateLoader<'a> { fn maybe_resolve_crate<'b>( &'b mut self, name: Symbol, - mut dep_kind: DepKind, + mut dep_kind: CrateDepKind, dep: Option<(&'b CratePaths, &'b CrateDep)>, ) -> Result { info!("resolving crate `{}`", name); @@ -475,7 +475,7 @@ impl<'a> CrateLoader<'a> { match self.load(&mut locator)? { Some(res) => (res, None), None => { - dep_kind = DepKind::MacrosOnly; + dep_kind = CrateDepKind::MacrosOnly; match self.load_proc_macro(&mut locator, path_kind)? { Some(res) => res, None => return Err(locator.into_error()), @@ -488,7 +488,7 @@ impl<'a> CrateLoader<'a> { (LoadResult::Previous(cnum), None) => { let data = self.cstore.get_crate_data(cnum); if data.is_proc_macro_crate() { - dep_kind = DepKind::MacrosOnly; + dep_kind = CrateDepKind::MacrosOnly; } data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind)); Ok(cnum) @@ -548,7 +548,7 @@ impl<'a> CrateLoader<'a> { crate_root: &CrateRoot<'_>, metadata: &MetadataBlob, krate: CrateNum, - dep_kind: DepKind, + dep_kind: CrateDepKind, ) -> Result { debug!("resolving deps of external crate"); if crate_root.is_proc_macro_crate() { @@ -567,7 +567,7 @@ impl<'a> CrateLoader<'a> { dep.name, dep.hash, dep.extra_filename ); let dep_kind = match dep_kind { - DepKind::MacrosOnly => DepKind::MacrosOnly, + CrateDepKind::MacrosOnly => CrateDepKind::MacrosOnly, _ => dep.kind, }; let cnum = self.maybe_resolve_crate(dep.name, dep_kind, Some((root, &dep)))?; @@ -634,7 +634,7 @@ impl<'a> CrateLoader<'a> { self.inject_dependency_if(cnum, "a panic runtime", &|data| { data.needs_panic_runtime() }); - runtime_found = runtime_found || data.dep_kind() == DepKind::Explicit; + runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit; } }); @@ -663,7 +663,7 @@ impl<'a> CrateLoader<'a> { }; info!("panic runtime not found -- loading {}", name); - let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None); + let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None); let data = self.cstore.get_crate_data(cnum); // Sanity check the loaded crate to ensure it is indeed a panic runtime @@ -693,7 +693,7 @@ impl<'a> CrateLoader<'a> { info!("loading profiler"); let name = sym::profiler_builtins; - let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None); + let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None); let data = self.cstore.get_crate_data(cnum); // Sanity check the loaded crate to ensure it is indeed a profiler runtime @@ -891,9 +891,9 @@ impl<'a> CrateLoader<'a> { None => item.ident.name, }; let dep_kind = if attr::contains_name(&item.attrs, sym::no_link) { - DepKind::MacrosOnly + CrateDepKind::MacrosOnly } else { - DepKind::Explicit + CrateDepKind::Explicit }; let cnum = self.resolve_crate(name, item.span, dep_kind, None); @@ -915,7 +915,7 @@ impl<'a> CrateLoader<'a> { } pub fn process_path_extern(&mut self, name: Symbol, span: Span) -> CrateNum { - let cnum = self.resolve_crate(name, span, DepKind::Explicit, None); + let cnum = self.resolve_crate(name, span, CrateDepKind::Explicit, None); self.update_extern_crate( cnum, @@ -932,6 +932,6 @@ impl<'a> CrateLoader<'a> { } pub fn maybe_process_path_extern(&mut self, name: Symbol) -> Option { - self.maybe_resolve_crate(name, DepKind::Explicit, None).ok() + self.maybe_resolve_crate(name, CrateDepKind::Explicit, None).ok() } } diff --git a/src/librustc_metadata/dependency_format.rs b/src/librustc_metadata/dependency_format.rs index aa5fafcc614b6..bb5ae4d0557c9 100644 --- a/src/librustc_metadata/dependency_format.rs +++ b/src/librustc_metadata/dependency_format.rs @@ -56,7 +56,7 @@ use crate::creader::CStore; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::CrateNum; use rustc_middle::middle::cstore::LinkagePreference::{self, RequireDynamic, RequireStatic}; -use rustc_middle::middle::cstore::{self, DepKind}; +use rustc_middle::middle::cstore::{self, CrateDepKind}; use rustc_middle::middle::dependency_format::{Dependencies, DependencyList, Linkage}; use rustc_middle::ty::TyCtxt; use rustc_session::config::CrateType; @@ -188,7 +188,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList { let src = tcx.used_crate_source(cnum); if src.dylib.is_none() && !formats.contains_key(&cnum) - && tcx.dep_kind(cnum) == DepKind::Explicit + && tcx.dep_kind(cnum) == CrateDepKind::Explicit { assert!(src.rlib.is_some() || src.rmeta.is_some()); log::info!("adding staticlib: {}", tcx.crate_name(cnum)); @@ -284,7 +284,7 @@ fn attempt_static(tcx: TyCtxt<'_>) -> Option { let last_crate = tcx.crates().len(); let mut ret = (1..last_crate + 1) .map(|cnum| { - if tcx.dep_kind(CrateNum::new(cnum)) == DepKind::Explicit { + if tcx.dep_kind(CrateNum::new(cnum)) == CrateDepKind::Explicit { Linkage::Static } else { Linkage::NotLinked diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index b7f5921438f8a..9afab42d1bbc3 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -100,7 +100,7 @@ crate struct CrateMetadata { /// Same ID set as `cnum_map` plus maybe some injected crates like panic runtime. dependencies: Lock>, /// How to link (or not link) this crate to the currently compiled crate. - dep_kind: Lock, + dep_kind: Lock, /// Filesystem location of this crate. source: CrateSource, /// Whether or not this crate should be consider a private dependency @@ -1670,7 +1670,7 @@ impl CrateMetadata { raw_proc_macros: Option<&'static [ProcMacro]>, cnum: CrateNum, cnum_map: CrateNumMap, - dep_kind: DepKind, + dep_kind: CrateDepKind, source: CrateSource, private_dep: bool, host_hash: Option, @@ -1728,11 +1728,11 @@ impl CrateMetadata { &self.source } - crate fn dep_kind(&self) -> DepKind { + crate fn dep_kind(&self) -> CrateDepKind { *self.dep_kind.lock() } - crate fn update_dep_kind(&self, f: impl FnOnce(DepKind) -> DepKind) { + crate fn update_dep_kind(&self, f: impl FnOnce(CrateDepKind) -> CrateDepKind) { self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind)) } diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index 55ef66f1939c4..fa8724251978b 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -11,7 +11,7 @@ use rustc_hir::def_id::{DefId, DefIndex}; use rustc_hir::lang_items; use rustc_index::{bit_set::FiniteBitSet, vec::IndexVec}; use rustc_middle::hir::exports::Export; -use rustc_middle::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLib}; +use rustc_middle::middle::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib}; use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel}; use rustc_middle::mir; use rustc_middle::ty::{self, ReprOptions, Ty}; @@ -226,7 +226,7 @@ crate struct CrateDep { pub name: Symbol, pub hash: Svh, pub host_hash: Option, - pub kind: DepKind, + pub kind: CrateDepKind, pub extra_filename: String, } diff --git a/src/librustc_middle/middle/cstore.rs b/src/librustc_middle/middle/cstore.rs index 97e877df96663..0a34c06adf063 100644 --- a/src/librustc_middle/middle/cstore.rs +++ b/src/librustc_middle/middle/cstore.rs @@ -40,7 +40,7 @@ impl CrateSource { #[derive(RustcEncodable, RustcDecodable, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)] #[derive(HashStable)] -pub enum DepKind { +pub enum CrateDepKind { /// A dependency that is only used for its macros. MacrosOnly, /// A dependency that is always injected into the dependency list and so @@ -51,11 +51,11 @@ pub enum DepKind { Explicit, } -impl DepKind { +impl CrateDepKind { pub fn macros_only(self) -> bool { match self { - DepKind::MacrosOnly => true, - DepKind::Implicit | DepKind::Explicit => false, + CrateDepKind::MacrosOnly => true, + CrateDepKind::Implicit | CrateDepKind::Explicit => false, } } } diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index f857af28622d1..a5562c867d7c6 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -1180,7 +1180,7 @@ rustc_queries! { } Other { - query dep_kind(_: CrateNum) -> DepKind { + query dep_kind(_: CrateNum) -> CrateDepKind { eval_always desc { "fetching what a dependency looks like" } } diff --git a/src/librustc_middle/ty/query/mod.rs b/src/librustc_middle/ty/query/mod.rs index 2f7a9aee536d8..b39c0b5190a6d 100644 --- a/src/librustc_middle/ty/query/mod.rs +++ b/src/librustc_middle/ty/query/mod.rs @@ -1,10 +1,10 @@ -use crate::dep_graph::{self, DepNode, DepNodeParams}; +use crate::dep_graph::{self, DepKind, DepNode, DepNodeParams}; use crate::hir::exports::Export; use crate::hir::map; use crate::infer::canonical::{self, Canonical}; use crate::lint::LintLevelMap; use crate::middle::codegen_fn_attrs::CodegenFnAttrs; -use crate::middle::cstore::{CrateSource, DepKind}; +use crate::middle::cstore::{CrateDepKind, CrateSource}; use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib}; use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel}; use crate::middle::lib_features::LibFeatures; @@ -161,7 +161,7 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool // hit the cache instead of having to go through `force_from_dep_node`. // This assertion makes sure, we actually keep applying the solution above. debug_assert!( - dep_node.kind != crate::dep_graph::DepKind::codegen_unit, + dep_node.kind != DepKind::codegen_unit, "calling force_from_dep_node() on DepKind::codegen_unit" ); @@ -172,14 +172,14 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool rustc_dep_node_force!([dep_node, tcx] // These are inputs that are expected to be pre-allocated and that // should therefore always be red or green already. - crate::dep_graph::DepKind::CrateMetadata | + DepKind::CrateMetadata | // These are anonymous nodes. - crate::dep_graph::DepKind::TraitSelect | + DepKind::TraitSelect | // We don't have enough information to reconstruct the query key of // these. - crate::dep_graph::DepKind::CompileCodegenUnit => { + DepKind::CompileCodegenUnit => { bug!("force_from_dep_node: encountered {:?}", dep_node) } ); From cc7abc7563ac6eb503023b2c4383cfb526a03962 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 2 Aug 2020 10:54:13 -0400 Subject: [PATCH 15/15] Avoid dumping rustc invocations to stdout These are quite long, usually, and in most cases not interesting. On smaller terminals they can take up more than a full page of output, hiding the error diagnostics emitted. --- src/bootstrap/bin/rustc.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index d6649d0521ca3..4dd71ebade1a4 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -171,7 +171,9 @@ fn main() { // note: everything below here is unreachable. do not put code that // should run on success, after this block. } - println!("\nDid not run successfully: {}\n{:?}\n-------------", status, cmd); + if verbose > 0 { + println!("\nDid not run successfully: {}\n{:?}\n-------------", status, cmd); + } if let Some(mut on_fail) = on_fail { on_fail.status().expect("Could not run the on_fail command");