diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-01 16:08:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-01 16:08:03 +0100 |
| commit | 741b62af0749ddf88ebbd7cad6ec7a15ab1fc1cb (patch) | |
| tree | b62e7a5a65776cd884bad216586ad4cefbb7452a /library/std/src | |
| parent | 788f2969f6d2f7339c3c1e7da225d38283597804 (diff) | |
| parent | 4bbe970673e8b982e2c94d17cd860c2c89ca5211 (diff) | |
| download | rust-741b62af0749ddf88ebbd7cad6ec7a15ab1fc1cb.tar.gz rust-741b62af0749ddf88ebbd7cad6ec7a15ab1fc1cb.zip | |
Rollup merge of #92584 - lcnr:query-stable-lint, r=estebank
add rustc lint, warning when iterating over hashmaps 2 first introduced in #89558 and reverted in #90380 due to its perf impact r? ``@estebank``
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/collections/hash/map.rs | 10 | ||||
| -rw-r--r-- | library/std/src/collections/hash/set.rs | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index c64377dfbc8..9e61defc31e 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -371,6 +371,7 @@ impl<K, V, S> HashMap<K, V, S> { /// assert_eq!(vec, ["a", "b", "c"]); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "map_into_keys_values", since = "1.54.0")] pub fn into_keys(self) -> IntoKeys<K, V> { IntoKeys { inner: self.into_iter() } @@ -448,6 +449,7 @@ impl<K, V, S> HashMap<K, V, S> { /// assert_eq!(vec, [1, 2, 3]); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "map_into_keys_values", since = "1.54.0")] pub fn into_values(self) -> IntoValues<K, V> { IntoValues { inner: self.into_iter() } @@ -471,6 +473,7 @@ impl<K, V, S> HashMap<K, V, S> { /// println!("key: {} val: {}", key, val); /// } /// ``` + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "rust1", since = "1.0.0")] pub fn iter(&self) -> Iter<'_, K, V> { Iter { base: self.base.iter() } @@ -500,6 +503,7 @@ impl<K, V, S> HashMap<K, V, S> { /// println!("key: {} val: {}", key, val); /// } /// ``` + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "rust1", since = "1.0.0")] pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { IterMut { base: self.base.iter_mut() } @@ -560,6 +564,7 @@ impl<K, V, S> HashMap<K, V, S> { /// assert!(a.is_empty()); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self) -> Drain<'_, K, V> { Drain { base: self.base.drain() } @@ -601,6 +606,7 @@ impl<K, V, S> HashMap<K, V, S> { /// assert_eq!(odds, vec![1, 3, 5, 7]); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[unstable(feature = "hash_drain_filter", issue = "59618")] pub fn drain_filter<F>(&mut self, pred: F) -> DrainFilter<'_, K, V, F> where @@ -624,6 +630,7 @@ impl<K, V, S> HashMap<K, V, S> { /// assert_eq!(map.len(), 4); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "retain_hash_collection", since = "1.18.0")] pub fn retain<F>(&mut self, f: F) where @@ -1990,6 +1997,7 @@ impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S> { type IntoIter = Iter<'a, K, V>; #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] fn into_iter(self) -> Iter<'a, K, V> { self.iter() } @@ -2001,6 +2009,7 @@ impl<'a, K, V, S> IntoIterator for &'a mut HashMap<K, V, S> { type IntoIter = IterMut<'a, K, V>; #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] fn into_iter(self) -> IterMut<'a, K, V> { self.iter_mut() } @@ -2030,6 +2039,7 @@ impl<K, V, S> IntoIterator for HashMap<K, V, S> { /// let vec: Vec<(&str, i32)> = map.into_iter().collect(); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] fn into_iter(self) -> IntoIter<K, V> { IntoIter { base: self.base.into_iter() } } diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 0d087772bf9..d1450987e73 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -185,6 +185,7 @@ impl<T, S> HashSet<T, S> { /// } /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "rust1", since = "1.0.0")] pub fn iter(&self) -> Iter<'_, T> { Iter { base: self.base.iter() } @@ -244,6 +245,7 @@ impl<T, S> HashSet<T, S> { /// assert!(set.is_empty()); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self) -> Drain<'_, T> { Drain { base: self.base.drain() } @@ -282,6 +284,7 @@ impl<T, S> HashSet<T, S> { /// assert_eq!(odds, vec![1, 3, 5, 7]); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[unstable(feature = "hash_drain_filter", issue = "59618")] pub fn drain_filter<F>(&mut self, pred: F) -> DrainFilter<'_, T, F> where @@ -304,6 +307,7 @@ impl<T, S> HashSet<T, S> { /// set.retain(|&k| k % 2 == 0); /// assert_eq!(set.len(), 3); /// ``` + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "retain_hash_collection", since = "1.18.0")] pub fn retain<F>(&mut self, f: F) where @@ -528,6 +532,7 @@ where /// assert_eq!(diff, [4].iter().collect()); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "rust1", since = "1.0.0")] pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S> { Difference { iter: self.iter(), other } @@ -555,6 +560,7 @@ where /// assert_eq!(diff1, [1, 4].iter().collect()); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "rust1", since = "1.0.0")] pub fn symmetric_difference<'a>( &'a self, @@ -582,6 +588,7 @@ where /// assert_eq!(intersection, [2, 3].iter().collect()); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "rust1", since = "1.0.0")] pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S> { if self.len() <= other.len() { @@ -610,6 +617,7 @@ where /// assert_eq!(union, [1, 2, 3, 4].iter().collect()); /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] #[stable(feature = "rust1", since = "1.0.0")] pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> { if self.len() >= other.len() { @@ -1410,6 +1418,7 @@ impl<'a, T, S> IntoIterator for &'a HashSet<T, S> { type IntoIter = Iter<'a, T>; #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] fn into_iter(self) -> Iter<'a, T> { self.iter() } @@ -1441,6 +1450,7 @@ impl<T, S> IntoIterator for HashSet<T, S> { /// } /// ``` #[inline] + #[cfg_attr(not(bootstrap), rustc_lint_query_instability)] fn into_iter(self) -> IntoIter<T> { IntoIter { base: self.base.into_iter() } } |
