From 4bd6be9dc6055d0cf0d36b1d6bcd8bfef545698f Mon Sep 17 00:00:00 2001 From: Badel2 <2badel2@gmail.com> Date: Fri, 3 Nov 2017 18:17:44 +0100 Subject: [PATCH] Inclusive range updated to `..=` syntax --- src/libcore/slice/mod.rs | 15 ++++++--------- src/librustc/ty/maps/on_disk_cache.rs | 2 +- src/libsyntax/print/pprust.rs | 2 +- src/test/run-pass-fulldeps/issue-35829.rs | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 57e5ae28664..25d7d0e3b0c 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -16,9 +16,6 @@ #![stable(feature = "rust1", since = "1.0.0")] -// FIXME: after next stage0, change RangeInclusive { ... } back to ..= -use ops::RangeInclusive; - // How this module is organized. // // The library infrastructure for slices is fairly messy. There's @@ -1047,32 +1044,32 @@ impl SliceIndex<[T]> for ops::RangeToInclusive { #[inline] fn get(self, slice: &[T]) -> Option<&[T]> { - (RangeInclusive { start: 0, end: self.end }).get(slice) + (0..=self.end).get(slice) } #[inline] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { - (RangeInclusive { start: 0, end: self.end }).get_mut(slice) + (0..=self.end).get_mut(slice) } #[inline] unsafe fn get_unchecked(self, slice: &[T]) -> &[T] { - (RangeInclusive { start: 0, end: self.end }).get_unchecked(slice) + (0..=self.end).get_unchecked(slice) } #[inline] unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] { - (RangeInclusive { start: 0, end: self.end }).get_unchecked_mut(slice) + (0..=self.end).get_unchecked_mut(slice) } #[inline] fn index(self, slice: &[T]) -> &[T] { - (RangeInclusive { start: 0, end: self.end }).index(slice) + (0..=self.end).index(slice) } #[inline] fn index_mut(self, slice: &mut [T]) -> &mut [T] { - (RangeInclusive { start: 0, end: self.end }).index_mut(slice) + (0..=self.end).index_mut(slice) } } diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/maps/on_disk_cache.rs index 26581501234..24ce8fb2995 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/maps/on_disk_cache.rs @@ -165,7 +165,7 @@ impl<'a> CacheDecoder<'a> { fn find_filemap_prev_bytepos(&self, prev_bytepos: BytePos) -> Option<(BytePos, StableFilemapId)> { - for (start, id) in self.prev_filemap_starts.range(BytePos(0) ... prev_bytepos).rev() { + for (start, id) in self.prev_filemap_starts.range(BytePos(0) ..= prev_bytepos).rev() { return Some((*start, *id)) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8a970fd4098..f0243967421 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2203,7 +2203,7 @@ impl<'a> State<'a> { if limits == ast::RangeLimits::HalfOpen { self.s.word("..")?; } else { - self.s.word("...")?; + self.s.word("..=")?; } if let Some(ref e) = *end { self.print_expr_maybe_paren(e, fake_prec)?; diff --git a/src/test/run-pass-fulldeps/issue-35829.rs b/src/test/run-pass-fulldeps/issue-35829.rs index 0a4c15a9236..f17a0494a69 100644 --- a/src/test/run-pass-fulldeps/issue-35829.rs +++ b/src/test/run-pass-fulldeps/issue-35829.rs @@ -41,8 +41,8 @@ fn main() { let raw_byte_string_lit_kind = LitKind::ByteStr(Rc::new(b"#\"two\"#".to_vec())); assert_eq!(raw_byte_string.node, ExprKind::Lit(P(dummy_spanned(raw_byte_string_lit_kind)))); - // check dotdotdot - let closed_range = quote_expr!(&cx, 0 ... 1); + // check dotdoteq + let closed_range = quote_expr!(&cx, 0 ..= 1); assert_eq!(closed_range.node, ExprKind::Range( Some(quote_expr!(&cx, 0)), Some(quote_expr!(&cx, 1)),