about summary refs log tree commit diff
path: root/compiler/rustc_span
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-17 09:28:14 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-20 08:11:05 +0200
commit3435683fd5930676b5a7ccd40dc08e4758e8b90a (patch)
tree74920e5620b83156a7e5d8b28e83e141432a98f2 /compiler/rustc_span
parent255a4c58f5863ed41c2e68792799125c6c676575 (diff)
downloadrust-3435683fd5930676b5a7ccd40dc08e4758e8b90a.tar.gz
rust-3435683fd5930676b5a7ccd40dc08e4758e8b90a.zip
use `array_windows` instead of `windows` in the compiler
Diffstat (limited to 'compiler/rustc_span')
-rw-r--r--compiler/rustc_span/src/lib.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index e38cd516b91..e817fa56c55 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -5,6 +5,7 @@
 //! This API is completely unstable and subject to change.
 
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
+#![feature(array_windows)]
 #![feature(crate_visibility_modifier)]
 #![feature(const_fn)]
 #![feature(const_panic)]
@@ -1158,7 +1159,12 @@ impl<S: Encoder> Encodable<S> for SourceFile {
                     let max_line_length = if lines.len() == 1 {
                         0
                     } else {
-                        lines.windows(2).map(|w| w[1] - w[0]).map(|bp| bp.to_usize()).max().unwrap()
+                        lines
+                            .array_windows()
+                            .map(|&[fst, snd]| snd - fst)
+                            .map(|bp| bp.to_usize())
+                            .max()
+                            .unwrap()
                     };
 
                     let bytes_per_diff: u8 = match max_line_length {
@@ -1173,7 +1179,7 @@ impl<S: Encoder> Encodable<S> for SourceFile {
                     // Encode the first element.
                     lines[0].encode(s)?;
 
-                    let diff_iter = (&lines[..]).windows(2).map(|w| (w[1] - w[0]));
+                    let diff_iter = lines[..].array_windows().map(|&[fst, snd]| snd - fst);
 
                     match bytes_per_diff {
                         1 => {