diff options
| author | Ralf Jung <post@ralfj.de> | 2020-09-20 12:08:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-20 12:08:26 +0200 |
| commit | 50d56bc774f9ecb2b43640651401f3cb346c1b89 (patch) | |
| tree | eb0a2096eb5f22ed3c126d0ec3ed6fbac5970398 /compiler/rustc_data_structures | |
| parent | df4e4ef2b9c6674cc93444b925ca8c3d0c17ab90 (diff) | |
| parent | bfb221b21e13e8fd71a8fc3a2df23e7f0e775df3 (diff) | |
| download | rust-50d56bc774f9ecb2b43640651401f3cb346c1b89.tar.gz rust-50d56bc774f9ecb2b43640651401f3cb346c1b89.zip | |
Rollup merge of #76825 - lcnr:array-windows-apply, r=varkor
use `array_windows` instead of `windows` in the compiler I do think these changes are beautiful, but do have to admit that using type inference for the window length can easily be confusing. This seems like a general issue with const generics, where inferring constants adds an additional complexity which users have to learn and keep in mind.
Diffstat (limited to 'compiler/rustc_data_structures')
| -rw-r--r-- | compiler/rustc_data_structures/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/sorted_map.rs | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 21a5071631c..8dafcdf3bc6 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -8,6 +8,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![allow(incomplete_features)] +#![feature(array_windows)] #![feature(control_flow_enum)] #![feature(in_band_lifetimes)] #![feature(unboxed_closures)] diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 856eb73e629..4807380595d 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -34,7 +34,7 @@ impl<K: Ord, V> SortedMap<K, V> { /// and that there are no duplicates. #[inline] pub fn from_presorted_elements(elements: Vec<(K, V)>) -> SortedMap<K, V> { - debug_assert!(elements.windows(2).all(|w| w[0].0 < w[1].0)); + debug_assert!(elements.array_windows().all(|[fst, snd]| fst.0 < snd.0)); SortedMap { data: elements } } @@ -159,7 +159,7 @@ impl<K: Ord, V> SortedMap<K, V> { return; } - debug_assert!(elements.windows(2).all(|w| w[0].0 < w[1].0)); + debug_assert!(elements.array_windows().all(|[fst, snd]| fst.0 < snd.0)); let start_index = self.lookup_index_for(&elements[0].0); |
