From 057715557b51af125847da6d19b2e016283c5ae7 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Mon, 28 May 2018 19:42:11 -0700 Subject: [PATCH] migrate codebase to `..=` inclusive range patterns These were stabilized in March 2018's #47813, and are the Preferred Way to Do It going forward (q.v. #51043). --- src/libcore/ascii.rs | 4 +- src/libcore/char/decode.rs | 18 +++---- src/libcore/char/methods.rs | 18 +++---- src/libcore/fmt/num.rs | 14 ++--- src/libcore/slice/mod.rs | 6 +-- src/libcore/str/lossy.rs | 14 ++--- src/libcore/str/mod.rs | 14 ++--- src/libcore/tests/slice.rs | 4 +- src/librustc_apfloat/ieee.rs | 4 +- src/librustc_codegen_utils/symbol_names.rs | 2 +- src/librustc_mir/diagnostics.rs | 4 +- src/librustc_mir/hair/pattern/check_match.rs | 2 +- src/librustc_target/abi/call/mod.rs | 10 ++-- src/librustc_target/abi/mod.rs | 16 +++--- src/librustc_typeck/diagnostics.rs | 6 +-- src/libserialize/hex.rs | 6 +-- src/libserialize/json.rs | 22 ++++---- src/libstd/sys_common/backtrace.rs | 2 +- src/libstd/sys_common/wtf8.rs | 12 ++--- src/libsyntax/ast.rs | 4 +- src/libsyntax/parse/lexer/mod.rs | 4 +- src/libsyntax_ext/format_foreign.rs | 14 ++--- src/libsyntax_pos/lib.rs | 4 +- src/libterm/terminfo/parm.rs | 10 ++-- src/test/compile-fail/associated-path-shl.rs | 2 +- src/test/compile-fail/issue-27895.rs | 2 +- src/test/compile-fail/issue-41255.rs | 2 +- src/test/compile-fail/match-range-fail-2.rs | 4 +- src/test/compile-fail/match-range-fail.rs | 6 +-- .../non-constant-in-const-path.rs | 2 +- .../compile-fail/patkind-litrange-no-expr.rs | 3 +- .../compile-fail/qualified-path-params.rs | 2 +- .../compile-fail/refutable-pattern-errors.rs | 4 +- .../run-pass-fulldeps/ast_stmt_expr_attr.rs | 8 +-- src/test/run-pass/byte-literals.rs | 2 +- .../inferred-suffix-in-pattern-range.rs | 6 +-- src/test/run-pass/issue-12582.rs | 4 +- src/test/run-pass/issue-13027.rs | 52 +++++++++---------- src/test/run-pass/issue-13867.rs | 14 ++--- src/test/run-pass/issue-18060.rs | 6 +-- src/test/run-pass/issue-18464.rs | 2 +- src/test/run-pass/issue-21475.rs | 6 +-- src/test/run-pass/issue-26251.rs | 4 +- src/test/run-pass/issue-35423.rs | 2 +- src/test/run-pass/issue-7222.rs | 2 +- src/test/run-pass/macro-literal.rs | 20 +++---- src/test/run-pass/match-range-infer.rs | 6 +-- src/test/run-pass/match-range-static.rs | 2 +- src/test/run-pass/match-range.rs | 14 ++--- .../rfc-2005-default-binding-mode/range.rs | 4 +- src/test/ui/check_match/issue-43253.rs | 8 +-- src/test/ui/check_match/issue-43253.stderr | 4 +- src/test/ui/const-eval/const_signed_pat.rs | 2 +- src/test/ui/const-eval/ref_to_int_match.rs | 4 +- .../ui/const-eval/ref_to_int_match.stderr | 2 +- src/test/ui/error-codes/E0029-teach.rs | 2 +- src/test/ui/error-codes/E0029-teach.stderr | 2 +- src/test/ui/error-codes/E0029.rs | 2 +- src/test/ui/error-codes/E0029.stderr | 2 +- src/test/ui/error-codes/E0030-teach.rs | 2 +- src/test/ui/error-codes/E0030-teach.stderr | 2 +- src/test/ui/error-codes/E0030.rs | 2 +- src/test/ui/error-codes/E0030.stderr | 2 +- src/test/ui/error-codes/E0308-4.rs | 2 +- src/test/ui/error-codes/E0308-4.stderr | 2 +- 65 files changed, 217 insertions(+), 218 deletions(-) diff --git a/src/libcore/ascii.rs b/src/libcore/ascii.rs index e6b0569281f..6ee91e0b22f 100644 --- a/src/libcore/ascii.rs +++ b/src/libcore/ascii.rs @@ -108,7 +108,7 @@ pub fn escape_default(c: u8) -> EscapeDefault { b'\\' => ([b'\\', b'\\', 0, 0], 2), b'\'' => ([b'\\', b'\'', 0, 0], 2), b'"' => ([b'\\', b'"', 0, 0], 2), - b'\x20' ... b'\x7e' => ([c, 0, 0, 0], 1), + b'\x20' ..= b'\x7e' => ([c, 0, 0, 0], 1), _ => ([b'\\', b'x', hexify(c >> 4), hexify(c & 0xf)], 4), }; @@ -116,7 +116,7 @@ pub fn escape_default(c: u8) -> EscapeDefault { fn hexify(b: u8) -> u8 { match b { - 0 ... 9 => b'0' + b, + 0 ..= 9 => b'0' + b, _ => b'a' + b - 10, } } diff --git a/src/libcore/char/decode.rs b/src/libcore/char/decode.rs index 45a73191db2..0b8dce19dff 100644 --- a/src/libcore/char/decode.rs +++ b/src/libcore/char/decode.rs @@ -64,7 +64,7 @@ impl> Iterator for DecodeUtf8 { } } macro_rules! continuation_byte { - () => { continuation_byte!(0x80...0xBF) }; + () => { continuation_byte!(0x80..=0xBF) }; ($range: pat) => { match self.0.peek() { Some(&byte @ $range) => { @@ -77,35 +77,35 @@ impl> Iterator for DecodeUtf8 { } match first_byte { - 0x00...0x7F => { + 0x00..=0x7F => { first_byte!(0b1111_1111); } - 0xC2...0xDF => { + 0xC2..=0xDF => { first_byte!(0b0001_1111); continuation_byte!(); } 0xE0 => { first_byte!(0b0000_1111); - continuation_byte!(0xA0...0xBF); // 0x80...0x9F here are overlong + continuation_byte!(0xA0..=0xBF); // 0x80..=0x9F here are overlong continuation_byte!(); } - 0xE1...0xEC | 0xEE...0xEF => { + 0xE1..=0xEC | 0xEE..=0xEF => { first_byte!(0b0000_1111); continuation_byte!(); continuation_byte!(); } 0xED => { first_byte!(0b0000_1111); - continuation_byte!(0x80...0x9F); // 0xA0..0xBF here are surrogates + continuation_byte!(0x80..=0x9F); // 0xA0..0xBF here are surrogates continuation_byte!(); } 0xF0 => { first_byte!(0b0000_0111); - continuation_byte!(0x90...0xBF); // 0x80..0x8F here are overlong + continuation_byte!(0x90..=0xBF); // 0x80..0x8F here are overlong continuation_byte!(); continuation_byte!(); } - 0xF1...0xF3 => { + 0xF1..=0xF3 => { first_byte!(0b0000_0111); continuation_byte!(); continuation_byte!(); @@ -113,7 +113,7 @@ impl> Iterator for DecodeUtf8 { } 0xF4 => { first_byte!(0b0000_0111); - continuation_byte!(0x80...0x8F); // 0x90..0xBF here are beyond char::MAX + continuation_byte!(0x80..=0x8F); // 0x90..0xBF here are beyond char::MAX continuation_byte!(); continuation_byte!(); } diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index f6b201fe06d..eee78de9036 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -125,9 +125,9 @@ impl char { panic!("to_digit: radix is too high (maximum 36)"); } let val = match self { - '0' ... '9' => self as u32 - '0' as u32, - 'a' ... 'z' => self as u32 - 'a' as u32 + 10, - 'A' ... 'Z' => self as u32 - 'A' as u32 + 10, + '0' ..= '9' => self as u32 - '0' as u32, + 'a' ..= 'z' => self as u32 - 'a' as u32 + 10, + 'A' ..= 'Z' => self as u32 - 'A' as u32 + 10, _ => return None, }; if val < radix { Some(val) } @@ -305,7 +305,7 @@ impl char { '\r' => EscapeDefaultState::Backslash('r'), '\n' => EscapeDefaultState::Backslash('n'), '\\' | '\'' | '"' => EscapeDefaultState::Backslash(self), - '\x20' ... '\x7e' => EscapeDefaultState::Char(self), + '\x20' ..= '\x7e' => EscapeDefaultState::Char(self), _ => EscapeDefaultState::Unicode(self.escape_unicode()) }; EscapeDefault { state: init_state } @@ -543,7 +543,7 @@ impl char { #[inline] pub fn is_alphabetic(self) -> bool { match self { - 'a'...'z' | 'A'...'Z' => true, + 'a'..='z' | 'A'..='Z' => true, c if c > '\x7f' => derived_property::Alphabetic(c), _ => false, } @@ -599,7 +599,7 @@ impl char { #[inline] pub fn is_lowercase(self) -> bool { match self { - 'a'...'z' => true, + 'a'..='z' => true, c if c > '\x7f' => derived_property::Lowercase(c), _ => false, } @@ -627,7 +627,7 @@ impl char { #[inline] pub fn is_uppercase(self) -> bool { match self { - 'A'...'Z' => true, + 'A'..='Z' => true, c if c > '\x7f' => derived_property::Uppercase(c), _ => false, } @@ -654,7 +654,7 @@ impl char { #[inline] pub fn is_whitespace(self) -> bool { match self { - ' ' | '\x09'...'\x0d' => true, + ' ' | '\x09'..='\x0d' => true, c if c > '\x7f' => property::White_Space(c), _ => false, } @@ -737,7 +737,7 @@ impl char { #[inline] pub fn is_numeric(self) -> bool { match self { - '0'...'9' => true, + '0'..='9' => true, c if c > '\x7f' => general_category::N(c), _ => false, } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 4451ab445cc..51391fa50d5 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -121,19 +121,19 @@ macro_rules! radix { fn digit(x: u8) -> u8 { match x { $($x => $conv,)+ - x => panic!("number not in the range 0..{}: {}", Self::BASE - 1, x), + x => panic!("number not in the range 0..={}: {}", Self::BASE - 1, x), } } } } } -radix! { Binary, 2, "0b", x @ 0 ... 1 => b'0' + x } -radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x } -radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'a' + (x - 10) } -radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'A' + (x - 10) } +radix! { Binary, 2, "0b", x @ 0 ..= 1 => b'0' + x } +radix! { Octal, 8, "0o", x @ 0 ..= 7 => b'0' + x } +radix! { LowerHex, 16, "0x", x @ 0 ..= 9 => b'0' + x, + x @ 10 ..= 15 => b'a' + (x - 10) } +radix! { UpperHex, 16, "0x", x @ 0 ..= 9 => b'0' + x, + x @ 10 ..= 15 => b'A' + (x - 10) } macro_rules! int_base { ($Trait:ident for $T:ident as $U:ident -> $Radix:ident) => { diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 6f4c130d8f3..e74e527927d 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1230,7 +1230,7 @@ impl [T] { /// assert_eq!(s.binary_search(&4), Err(7)); /// assert_eq!(s.binary_search(&100), Err(13)); /// let r = s.binary_search(&1); - /// assert!(match r { Ok(1...4) => true, _ => false, }); + /// assert!(match r { Ok(1..=4) => true, _ => false, }); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn binary_search(&self, x: &T) -> Result @@ -1268,7 +1268,7 @@ impl [T] { /// assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Err(13)); /// let seek = 1; /// let r = s.binary_search_by(|probe| probe.cmp(&seek)); - /// assert!(match r { Ok(1...4) => true, _ => false, }); + /// assert!(match r { Ok(1..=4) => true, _ => false, }); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -1325,7 +1325,7 @@ impl [T] { /// assert_eq!(s.binary_search_by_key(&4, |&(a,b)| b), Err(7)); /// assert_eq!(s.binary_search_by_key(&100, |&(a,b)| b), Err(13)); /// let r = s.binary_search_by_key(&1, |&(a,b)| b); - /// assert!(match r { Ok(1...4) => true, _ => false, }); + /// assert!(match r { Ok(1..=4) => true, _ => false, }); /// ``` #[stable(feature = "slice_binary_search_by_key", since = "1.10.0")] #[inline] diff --git a/src/libcore/str/lossy.rs b/src/libcore/str/lossy.rs index 30b7267da7c..5cfb36d3b19 100644 --- a/src/libcore/str/lossy.rs +++ b/src/libcore/str/lossy.rs @@ -101,10 +101,10 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> { } 3 => { match (byte, safe_get(self.source, i)) { - (0xE0, 0xA0 ... 0xBF) => (), - (0xE1 ... 0xEC, 0x80 ... 0xBF) => (), - (0xED, 0x80 ... 0x9F) => (), - (0xEE ... 0xEF, 0x80 ... 0xBF) => (), + (0xE0, 0xA0 ..= 0xBF) => (), + (0xE1 ..= 0xEC, 0x80 ..= 0xBF) => (), + (0xED, 0x80 ..= 0x9F) => (), + (0xEE ..= 0xEF, 0x80 ..= 0xBF) => (), _ => { error!(); } @@ -117,9 +117,9 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> { } 4 => { match (byte, safe_get(self.source, i)) { - (0xF0, 0x90 ... 0xBF) => (), - (0xF1 ... 0xF3, 0x80 ... 0xBF) => (), - (0xF4, 0x80 ... 0x8F) => (), + (0xF0, 0x90 ..= 0xBF) => (), + (0xF1 ..= 0xF3, 0x80 ..= 0xBF) => (), + (0xF4, 0x80 ..= 0x8F) => (), _ => { error!(); } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 5e1a9c25a21..42fb1bc238b 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1484,10 +1484,10 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> { }, 3 => { match (first, next!()) { - (0xE0 , 0xA0 ... 0xBF) | - (0xE1 ... 0xEC, 0x80 ... 0xBF) | - (0xED , 0x80 ... 0x9F) | - (0xEE ... 0xEF, 0x80 ... 0xBF) => {} + (0xE0 , 0xA0 ..= 0xBF) | + (0xE1 ..= 0xEC, 0x80 ..= 0xBF) | + (0xED , 0x80 ..= 0x9F) | + (0xEE ..= 0xEF, 0x80 ..= 0xBF) => {} _ => err!(Some(1)) } if next!() & !CONT_MASK != TAG_CONT_U8 { @@ -1496,9 +1496,9 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> { } 4 => { match (first, next!()) { - (0xF0 , 0x90 ... 0xBF) | - (0xF1 ... 0xF3, 0x80 ... 0xBF) | - (0xF4 , 0x80 ... 0x8F) => {} + (0xF0 , 0x90 ..= 0xBF) | + (0xF1 ..= 0xF3, 0x80 ..= 0xBF) | + (0xF4 , 0x80 ..= 0x8F) => {} _ => err!(Some(1)) } if next!() & !CONT_MASK != TAG_CONT_U8 { diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index fcd79222e16..7981567067d 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -60,8 +60,8 @@ fn test_binary_search() { assert_eq!(b.binary_search(&0), Err(0)); assert_eq!(b.binary_search(&1), Ok(0)); assert_eq!(b.binary_search(&2), Err(1)); - assert!(match b.binary_search(&3) { Ok(1...3) => true, _ => false }); - assert!(match b.binary_search(&3) { Ok(1...3) => true, _ => false }); + assert!(match b.binary_search(&3) { Ok(1..=3) => true, _ => false }); + assert!(match b.binary_search(&3) { Ok(1..=3) => true, _ => false }); assert_eq!(b.binary_search(&4), Err(4)); assert_eq!(b.binary_search(&5), Err(4)); assert_eq!(b.binary_search(&6), Err(4)); diff --git a/src/librustc_apfloat/ieee.rs b/src/librustc_apfloat/ieee.rs index 7abd02b6656..b21448df582 100644 --- a/src/librustc_apfloat/ieee.rs +++ b/src/librustc_apfloat/ieee.rs @@ -1753,9 +1753,9 @@ impl IeeeFloat { } else { loss = Some(match hex_value { 0 => Loss::ExactlyZero, - 1...7 => Loss::LessThanHalf, + 1..=7 => Loss::LessThanHalf, 8 => Loss::ExactlyHalf, - 9...15 => Loss::MoreThanHalf, + 9..=15 => Loss::MoreThanHalf, _ => unreachable!(), }); } diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index dcb82e5c424..ac71ecff964 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -424,7 +424,7 @@ pub fn sanitize(result: &mut String, s: &str) -> bool { '-' | ':' => result.push('.'), // These are legal symbols - 'a'...'z' | 'A'...'Z' | '0'...'9' | '_' | '.' | '$' => result.push(c), + 'a'..='z' | 'A'..='Z' | '0'..='9' | '_' | '.' | '$' => result.push(c), _ => { result.push('$'); diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs index f195775bf86..c2da1bee395 100644 --- a/src/librustc_mir/diagnostics.rs +++ b/src/librustc_mir/diagnostics.rs @@ -306,9 +306,9 @@ For example: ```compile_fail match 5u32 { // This range is ok, albeit pointless. - 1 ... 1 => {} + 1 ..= 1 => {} // This range is empty, and the compiler can tell. - 1000 ... 5 => {} + 1000 ..= 5 => {} } ``` "##, diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 4ac896d84ff..24301e970f5 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -481,7 +481,7 @@ fn check_exhaustive<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>, let joined_patterns = match witnesses.len() { 0 => bug!(), 1 => format!("`{}`", witnesses[0]), - 2...LIMIT => { + 2..=LIMIT => { let (tail, head) = witnesses.split_last().unwrap(); let head: Vec<_> = head.iter().map(|w| w.to_string()).collect(); format!("`{}` and `{}`", head.join("`, `"), tail) diff --git a/src/librustc_target/abi/call/mod.rs b/src/librustc_target/abi/call/mod.rs index fcae9ea22bb..3195823eb09 100644 --- a/src/librustc_target/abi/call/mod.rs +++ b/src/librustc_target/abi/call/mod.rs @@ -139,11 +139,11 @@ impl Reg { RegKind::Integer => { match self.size.bits() { 1 => dl.i1_align, - 2...8 => dl.i8_align, - 9...16 => dl.i16_align, - 17...32 => dl.i32_align, - 33...64 => dl.i64_align, - 65...128 => dl.i128_align, + 2..=8 => dl.i8_align, + 9..=16 => dl.i16_align, + 17..=32 => dl.i32_align, + 33..=64 => dl.i64_align, + 65..=128 => dl.i128_align, _ => panic!("unsupported integer: {:?}", self) } } diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 7ff04df6233..9003e30357c 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -441,10 +441,10 @@ impl Integer { /// Find the smallest Integer type which can represent the signed value. pub fn fit_signed(x: i128) -> Integer { match x { - -0x0000_0000_0000_0080...0x0000_0000_0000_007f => I8, - -0x0000_0000_0000_8000...0x0000_0000_0000_7fff => I16, - -0x0000_0000_8000_0000...0x0000_0000_7fff_ffff => I32, - -0x8000_0000_0000_0000...0x7fff_ffff_ffff_ffff => I64, + -0x0000_0000_0000_0080..=0x0000_0000_0000_007f => I8, + -0x0000_0000_0000_8000..=0x0000_0000_0000_7fff => I16, + -0x0000_0000_8000_0000..=0x0000_0000_7fff_ffff => I32, + -0x8000_0000_0000_0000..=0x7fff_ffff_ffff_ffff => I64, _ => I128 } } @@ -452,10 +452,10 @@ impl Integer { /// Find the smallest Integer type which can represent the unsigned value. pub fn fit_unsigned(x: u128) -> Integer { match x { - 0...0x0000_0000_0000_00ff => I8, - 0...0x0000_0000_0000_ffff => I16, - 0...0x0000_0000_ffff_ffff => I32, - 0...0xffff_ffff_ffff_ffff => I64, + 0..=0x0000_0000_0000_00ff => I8, + 0..=0x0000_0000_0000_ffff => I16, + 0..=0x0000_0000_ffff_ffff => I32, + 0..=0xffff_ffff_ffff_ffff => I64, _ => I128, } } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index b0b72256edc..dd09bf96da5 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -207,7 +207,7 @@ let string = "salutations !"; // The ordering relation for strings can't be evaluated at compile time, // so this doesn't work: match string { - "hello" ... "world" => {} + "hello" ..= "world" => {} _ => {} } @@ -2146,7 +2146,7 @@ fn main() -> i32 { 0 } let x = 1u8; match x { - 0u8...3i8 => (), + 0u8..=3i8 => (), // error: mismatched types in range: expected u8, found i8 _ => () } @@ -2189,7 +2189,7 @@ as the type you're matching on. Example: let x = 1u8; match x { - 0u8...3u8 => (), // ok! + 0u8..=3u8 => (), // ok! _ => () } ``` diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index b5b344e8d5f..4c306d9b2d3 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -125,9 +125,9 @@ impl FromHex for str { buf <<= 4; match byte { - b'A'...b'F' => buf |= byte - b'A' + 10, - b'a'...b'f' => buf |= byte - b'a' + 10, - b'0'...b'9' => buf |= byte - b'0', + b'A'..=b'F' => buf |= byte - b'A' + 10, + b'a'..=b'f' => buf |= byte - b'a' + 10, + b'0'..=b'9' => buf |= byte - b'0', b' '|b'\r'|b'\n'|b'\t' => { buf >>= 4; continue diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index efdad7d801a..9959d5ce40d 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1557,14 +1557,14 @@ impl> Parser { self.bump(); // A leading '0' must be the only digit before the decimal point. - if let '0' ... '9' = self.ch_or_null() { + if let '0' ..= '9' = self.ch_or_null() { return self.error(InvalidNumber) } }, - '1' ... '9' => { + '1' ..= '9' => { while !self.eof() { match self.ch_or_null() { - c @ '0' ... '9' => { + c @ '0' ..= '9' => { accum = accum.wrapping_mul(10); accum = accum.wrapping_add((c as u64) - ('0' as u64)); @@ -1588,14 +1588,14 @@ impl> Parser { // Make sure a digit follows the decimal place. match self.ch_or_null() { - '0' ... '9' => (), + '0' ..= '9' => (), _ => return self.error(InvalidNumber) } let mut dec = 1.0; while !self.eof() { match self.ch_or_null() { - c @ '0' ... '9' => { + c @ '0' ..= '9' => { dec /= 10.0; res += (((c as isize) - ('0' as isize)) as f64) * dec; self.bump(); @@ -1622,12 +1622,12 @@ impl> Parser { // Make sure a digit follows the exponent place. match self.ch_or_null() { - '0' ... '9' => (), + '0' ..= '9' => (), _ => return self.error(InvalidNumber) } while !self.eof() { match self.ch_or_null() { - c @ '0' ... '9' => { + c @ '0' ..= '9' => { exp *= 10; exp += (c as usize) - ('0' as usize); @@ -1653,7 +1653,7 @@ impl> Parser { while i < 4 && !self.eof() { self.bump(); n = match self.ch_or_null() { - c @ '0' ... '9' => n * 16 + ((c as u16) - ('0' as u16)), + c @ '0' ..= '9' => n * 16 + ((c as u16) - ('0' as u16)), 'a' | 'A' => n * 16 + 10, 'b' | 'B' => n * 16 + 11, 'c' | 'C' => n * 16 + 12, @@ -1695,13 +1695,13 @@ impl> Parser { 'r' => res.push('\r'), 't' => res.push('\t'), 'u' => match self.decode_hex_escape()? { - 0xDC00 ... 0xDFFF => { + 0xDC00 ..= 0xDFFF => { return self.error(LoneLeadingSurrogateInHexEscape) } // Non-BMP characters are encoded as a sequence of // two hex escapes, representing UTF-16 surrogates. - n1 @ 0xD800 ... 0xDBFF => { + n1 @ 0xD800 ..= 0xDBFF => { match (self.next_char(), self.next_char()) { (Some('\\'), Some('u')) => (), _ => return self.error(UnexpectedEndOfHexEscape), @@ -1928,7 +1928,7 @@ impl> Parser { 'n' => { self.parse_ident("ull", NullValue) } 't' => { self.parse_ident("rue", BooleanValue(true)) } 'f' => { self.parse_ident("alse", BooleanValue(false)) } - '0' ... '9' | '-' => self.parse_number(), + '0' ..= '9' | '-' => self.parse_number(), '"' => match self.parse_str() { Ok(s) => StringValue(s), Err(e) => Error(e), diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index 20109d2d0d5..61d7ed463dd 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -263,7 +263,7 @@ pub fn demangle(writer: &mut Write, mut s: &str, format: PrintFormat) -> io::Res let candidate = &s[i + llvm.len()..]; let all_hex = candidate.chars().all(|c| { match c { - 'A' ... 'F' | '0' ... '9' => true, + 'A' ..= 'F' | '0' ..= '9' => true, _ => false, } }); diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 14a2555adf9..bbb5980bd9d 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -76,7 +76,7 @@ impl CodePoint { #[inline] pub fn from_u32(value: u32) -> Option { match value { - 0 ... 0x10FFFF => Some(CodePoint { value: value }), + 0 ..= 0x10FFFF => Some(CodePoint { value: value }), _ => None } } @@ -101,7 +101,7 @@ impl CodePoint { #[inline] pub fn to_char(&self) -> Option { match self.value { - 0xD800 ... 0xDFFF => None, + 0xD800 ..= 0xDFFF => None, _ => Some(unsafe { char::from_u32_unchecked(self.value) }) } } @@ -305,7 +305,7 @@ impl Wtf8Buf { /// like concatenating ill-formed UTF-16 strings effectively would. #[inline] pub fn push(&mut self, code_point: CodePoint) { - if let trail @ 0xDC00...0xDFFF = code_point.to_u32() { + if let trail @ 0xDC00..=0xDFFF = code_point.to_u32() { if let Some(lead) = (&*self).final_lead_surrogate() { let len_without_lead_surrogate = self.len() - 3; self.bytes.truncate(len_without_lead_surrogate); @@ -525,7 +525,7 @@ impl Wtf8 { #[inline] pub fn ascii_byte_at(&self, position: usize) -> u8 { match self.bytes[position] { - ascii_byte @ 0x00 ... 0x7F => ascii_byte, + ascii_byte @ 0x00 ..= 0x7F => ascii_byte, _ => 0xFF } } @@ -630,7 +630,7 @@ impl Wtf8 { return None } match &self.bytes[(len - 3)..] { - &[0xED, b2 @ 0xA0...0xAF, b3] => Some(decode_surrogate(b2, b3)), + &[0xED, b2 @ 0xA0..=0xAF, b3] => Some(decode_surrogate(b2, b3)), _ => None } } @@ -642,7 +642,7 @@ impl Wtf8 { return None } match &self.bytes[..3] { - &[0xED, b2 @ 0xB0...0xBF, b3] => Some(decode_surrogate(b2, b3)), + &[0xED, b2 @ 0xB0..=0xBF, b3] => Some(decode_surrogate(b2, b3)), _ => None } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a57a9b95e5f..a09055e6c4a 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -843,11 +843,11 @@ pub struct Local { /// An arm of a 'match'. /// -/// E.g. `0...10 => { println!("match!") }` as in +/// E.g. `0..=10 => { println!("match!") }` as in /// /// ``` /// match 123 { -/// 0...10 => { println!("match!") }, +/// 0..=10 => { println!("match!") }, /// _ => { println!("no match!") }, /// } /// ``` diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 5353ff9a1e1..c09cfd910d2 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -266,7 +266,7 @@ impl<'a> StringReader<'a> { /// Pushes a character to a message string for error reporting fn push_escaped_char_for_msg(m: &mut String, c: char) { match c { - '\u{20}'...'\u{7e}' => { + '\u{20}'..='\u{7e}' => { // Don't escape \, ' or " for user-facing messages m.push(c); } @@ -779,7 +779,7 @@ impl<'a> StringReader<'a> { base = 16; num_digits = self.scan_digits(16, 16); } - '0'...'9' | '_' | '.' | 'e' | 'E' => { + '0'..='9' | '_' | '.' | 'e' | 'E' => { num_digits = self.scan_digits(10, 10) + 1; } _ => { diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index 0dd8f0c55d8..2393af76c34 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -374,7 +374,7 @@ pub mod printf { if let Start = state { match c { - '1'...'9' => { + '1'..='9' => { let end = at_next_cp_while(next, is_digit); match end.next_cp() { // Yes, this *is* the parameter. @@ -416,7 +416,7 @@ pub mod printf { state = WidthArg; move_to!(next); }, - '1' ... '9' => { + '1' ..= '9' => { let end = at_next_cp_while(next, is_digit); state = Prec; width = Some(Num::from_str(at.slice_between(end).unwrap(), None)); @@ -477,7 +477,7 @@ pub mod printf { } } }, - '0' ... '9' => { + '0' ..= '9' => { let end = at_next_cp_while(next, is_digit); state = Length; precision = Some(Num::from_str(at.slice_between(end).unwrap(), None)); @@ -570,7 +570,7 @@ pub mod printf { fn is_digit(c: char) -> bool { match c { - '0' ... '9' => true, + '0' ..= '9' => true, _ => false } } @@ -799,7 +799,7 @@ pub mod shell { let start = s.find('$')?; match s[start+1..].chars().next()? { '$' => return Some((Substitution::Escape, &s[start+2..])), - c @ '0' ... '9' => { + c @ '0' ..= '9' => { let n = (c as u8) - b'0'; return Some((Substitution::Ordinal(n), &s[start+2..])); }, @@ -836,14 +836,14 @@ pub mod shell { fn is_ident_head(c: char) -> bool { match c { - 'a' ... 'z' | 'A' ... 'Z' | '_' => true, + 'a' ..= 'z' | 'A' ..= 'Z' | '_' => true, _ => false } } fn is_ident_tail(c: char) -> bool { match c { - '0' ... '9' => true, + '0' ..= '9' => true, c => is_ident_head(c) } } diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index a4fb9571ecb..756e0c059a7 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -818,8 +818,8 @@ impl Encodable for FileMap { }; let bytes_per_diff: u8 = match max_line_length { - 0 ... 0xFF => 1, - 0x100 ... 0xFFFF => 2, + 0 ..= 0xFF => 1, + 0x100 ..= 0xFFFF => 2, _ => 4 }; diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index bd5ab92e8b0..b720d55594f 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -215,7 +215,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result { + ':' | '#' | ' ' | '.' | '0'..='9' => { let mut flags = Flags::new(); let mut fstate = FormatStateFlags; match cur { @@ -223,7 +223,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result flags.alternate = true, ' ' => flags.space = true, '.' => fstate = FormatStatePrecision, - '0'...'9' => { + '0'..='9' => { flags.width = cur as usize - '0' as usize; fstate = FormatStateWidth; } @@ -337,14 +337,14 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result { flags.space = true; } - (FormatStateFlags, '0'...'9') => { + (FormatStateFlags, '0'..='9') => { flags.width = cur as usize - '0' as usize; *fstate = FormatStateWidth; } (FormatStateFlags, '.') => { *fstate = FormatStatePrecision; } - (FormatStateWidth, '0'...'9') => { + (FormatStateWidth, '0'..='9') => { let old = flags.width; flags.width = flags.width * 10 + (cur as usize - '0' as usize); if flags.width < old { @@ -354,7 +354,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result { *fstate = FormatStatePrecision; } - (FormatStatePrecision, '0'...'9') => { + (FormatStatePrecision, '0'..='9') => { let old = flags.precision; flags.precision = flags.precision * 10 + (cur as usize - '0' as usize); if flags.precision < old { diff --git a/src/test/compile-fail/associated-path-shl.rs b/src/test/compile-fail/associated-path-shl.rs index 64afd702f5d..7daf0d3c4e2 100644 --- a/src/test/compile-fail/associated-path-shl.rs +++ b/src/test/compile-fail/associated-path-shl.rs @@ -14,7 +14,7 @@ fn main() { let _: <::B>::C; //~ ERROR cannot find type `A` in this scope let _ = <::B>::C; //~ ERROR cannot find type `A` in this scope let <::B>::C; //~ ERROR cannot find type `A` in this scope - let 0 ... <::B>::C; //~ ERROR cannot find type `A` in this scope + let 0 ..= <::B>::C; //~ ERROR cannot find type `A` in this scope //~^ ERROR only char and numeric types are allowed in range patterns <::B>::C; //~ ERROR cannot find type `A` in this scope } diff --git a/src/test/compile-fail/issue-27895.rs b/src/test/compile-fail/issue-27895.rs index be76796c5c4..6063755c04f 100644 --- a/src/test/compile-fail/issue-27895.rs +++ b/src/test/compile-fail/issue-27895.rs @@ -13,7 +13,7 @@ fn main() { let index = 6; match i { - 0...index => println!("winner"), + 0..=index => println!("winner"), //~^ ERROR runtime values cannot be referenced in patterns _ => println!("hello"), } diff --git a/src/test/compile-fail/issue-41255.rs b/src/test/compile-fail/issue-41255.rs index bdd502d4420..29912de37eb 100644 --- a/src/test/compile-fail/issue-41255.rs +++ b/src/test/compile-fail/issue-41255.rs @@ -27,7 +27,7 @@ fn main() { //~| WARNING hard error //~| ERROR floating-point types cannot be used in patterns //~| WARNING hard error - 39.0 ... 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns + 39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns //~| WARNING hard error //~| ERROR floating-point types cannot be used in patterns //~| WARNING hard error diff --git a/src/test/compile-fail/match-range-fail-2.rs b/src/test/compile-fail/match-range-fail-2.rs index 91ad2b3507a..b42e2ff919a 100644 --- a/src/test/compile-fail/match-range-fail-2.rs +++ b/src/test/compile-fail/match-range-fail-2.rs @@ -12,7 +12,7 @@ fn main() { match 5 { - 6 ... 1 => { } + 6 ..= 1 => { } _ => { } }; //~^^^ ERROR lower range bound must be less than or equal to upper @@ -24,7 +24,7 @@ fn main() { //~^^^ ERROR lower range bound must be less than upper match 5u64 { - 0xFFFF_FFFF_FFFF_FFFF ... 1 => { } + 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } _ => { } }; //~^^^ ERROR lower range bound must be less than or equal to upper diff --git a/src/test/compile-fail/match-range-fail.rs b/src/test/compile-fail/match-range-fail.rs index f89b3e39390..ca99b0c7b89 100644 --- a/src/test/compile-fail/match-range-fail.rs +++ b/src/test/compile-fail/match-range-fail.rs @@ -10,21 +10,21 @@ fn main() { match "wow" { - "bar" ... "foo" => { } + "bar" ..= "foo" => { } }; //~^^ ERROR only char and numeric types are allowed in range //~| start type: &'static str //~| end type: &'static str match "wow" { - 10 ... "what" => () + 10 ..= "what" => () }; //~^^ ERROR only char and numeric types are allowed in range //~| start type: {integer} //~| end type: &'static str match 5 { - 'c' ... 100 => { } + 'c' ..= 100 => { } _ => { } }; //~^^^ ERROR mismatched types diff --git a/src/test/compile-fail/non-constant-in-const-path.rs b/src/test/compile-fail/non-constant-in-const-path.rs index fe88ab4e117..1aae25105a8 100644 --- a/src/test/compile-fail/non-constant-in-const-path.rs +++ b/src/test/compile-fail/non-constant-in-const-path.rs @@ -11,7 +11,7 @@ fn main() { let x = 0; match 1 { - 0 ... x => {} + 0 ..= x => {} //~^ ERROR runtime values cannot be referenced in patterns }; } diff --git a/src/test/compile-fail/patkind-litrange-no-expr.rs b/src/test/compile-fail/patkind-litrange-no-expr.rs index d57a23f26c4..8fef98f815f 100644 --- a/src/test/compile-fail/patkind-litrange-no-expr.rs +++ b/src/test/compile-fail/patkind-litrange-no-expr.rs @@ -17,7 +17,7 @@ macro_rules! enum_number { fn foo(value: i32) -> Option<$name> { match value { $( $value => Some($name::$variant), )* // PatKind::Lit - $( $value ... 42 => Some($name::$variant), )* // PatKind::Range + $( $value ..= 42 => Some($name::$variant), )* // PatKind::Range _ => None } } @@ -32,4 +32,3 @@ enum_number!(Change { }); fn main() {} - diff --git a/src/test/compile-fail/qualified-path-params.rs b/src/test/compile-fail/qualified-path-params.rs index a7bc27e1749..018a3b2ae32 100644 --- a/src/test/compile-fail/qualified-path-params.rs +++ b/src/test/compile-fail/qualified-path-params.rs @@ -29,6 +29,6 @@ fn main() { match 10 { ::A::f:: => {} //~^ ERROR expected unit struct/variant or constant, found method `<::A>::f` - 0 ... ::A::f:: => {} //~ ERROR only char and numeric types are allowed in range + 0 ..= ::A::f:: => {} //~ ERROR only char and numeric types are allowed in range } } diff --git a/src/test/compile-fail/refutable-pattern-errors.rs b/src/test/compile-fail/refutable-pattern-errors.rs index ce93e1875ae..7b4009481ab 100644 --- a/src/test/compile-fail/refutable-pattern-errors.rs +++ b/src/test/compile-fail/refutable-pattern-errors.rs @@ -9,10 +9,10 @@ // except according to those terms. -fn func((1, (Some(1), 2...3)): (isize, (Option, isize))) { } +fn func((1, (Some(1), 2..=3)): (isize, (Option, isize))) { } //~^ ERROR refutable pattern in function argument: `(_, _)` not covered fn main() { - let (1, (Some(1), 2...3)) = (1, (None, 2)); + let (1, (Some(1), 2..=3)) = (1, (None, 2)); //~^ ERROR refutable pattern in local binding: `(_, _)` not covered } diff --git a/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs b/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs index 62cb870c7bb..f9d1ce34535 100644 --- a/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs +++ b/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs @@ -286,16 +286,16 @@ fn run() { // would require parens in patterns to allow disambiguation... reject_expr_parse("match 0 { - 0...#[attr] 10 => () + 0..=#[attr] 10 => () }"); reject_expr_parse("match 0 { - 0...#[attr] -10 => () + 0..=#[attr] -10 => () }"); reject_expr_parse("match 0 { - 0...-#[attr] 10 => () + 0..=-#[attr] 10 => () }"); reject_expr_parse("match 0 { - 0...#[attr] FOO => () + 0..=#[attr] FOO => () }"); // make sure we don't catch this bug again... diff --git a/src/test/run-pass/byte-literals.rs b/src/test/run-pass/byte-literals.rs index ad779d26f9e..f5acb72429a 100644 --- a/src/test/run-pass/byte-literals.rs +++ b/src/test/run-pass/byte-literals.rs @@ -36,7 +36,7 @@ pub fn main() { } match 100 { - b'a' ... b'z' => {}, + b'a' ..= b'z' => {}, _ => panic!() } diff --git a/src/test/run-pass/inferred-suffix-in-pattern-range.rs b/src/test/run-pass/inferred-suffix-in-pattern-range.rs index 22369c77ed3..89d26aade2e 100644 --- a/src/test/run-pass/inferred-suffix-in-pattern-range.rs +++ b/src/test/run-pass/inferred-suffix-in-pattern-range.rs @@ -12,21 +12,21 @@ pub fn main() { let x = 2; let x_message = match x { - 0 ... 1 => { "not many".to_string() } + 0 ..= 1 => { "not many".to_string() } _ => { "lots".to_string() } }; assert_eq!(x_message, "lots".to_string()); let y = 2; let y_message = match y { - 0 ... 1 => { "not many".to_string() } + 0 ..= 1 => { "not many".to_string() } _ => { "lots".to_string() } }; assert_eq!(y_message, "lots".to_string()); let z = 1u64; let z_message = match z { - 0 ... 1 => { "not many".to_string() } + 0 ..= 1 => { "not many".to_string() } _ => { "lots".to_string() } }; assert_eq!(z_message, "not many".to_string()); diff --git a/src/test/run-pass/issue-12582.rs b/src/test/run-pass/issue-12582.rs index 7bab2ddfed0..b89964d968e 100644 --- a/src/test/run-pass/issue-12582.rs +++ b/src/test/run-pass/issue-12582.rs @@ -16,7 +16,7 @@ pub fn main() { assert_eq!(3, match (x, y) { (1, 1) => 1, (2, 2) => 2, - (1...2, 2) => 3, + (1..=2, 2) => 3, _ => 4, }); @@ -24,7 +24,7 @@ pub fn main() { assert_eq!(3, match ((x, y),) { ((1, 1),) => 1, ((2, 2),) => 2, - ((1...2, 2),) => 3, + ((1..=2, 2),) => 3, _ => 4, }); } diff --git a/src/test/run-pass/issue-13027.rs b/src/test/run-pass/issue-13027.rs index d28ea94ec1a..2c460900ef6 100644 --- a/src/test/run-pass/issue-13027.rs +++ b/src/test/run-pass/issue-13027.rs @@ -30,7 +30,7 @@ pub fn main() { fn lit_shadow_range() { assert_eq!(2, match 1 { 1 if false => 1, - 1...2 => 2, + 1..=2 => 2, _ => 3 }); @@ -38,34 +38,34 @@ fn lit_shadow_range() { assert_eq!(2, match x+1 { 0 => 0, 1 if false => 1, - 1...2 => 2, + 1..=2 => 2, _ => 3 }); assert_eq!(2, match val() { 1 if false => 1, - 1...2 => 2, + 1..=2 => 2, _ => 3 }); assert_eq!(2, match CONST { 0 => 0, 1 if false => 1, - 1...2 => 2, + 1..=2 => 2, _ => 3 }); // value is out of the range of second arm, should match wildcard pattern assert_eq!(3, match 3 { 1 if false => 1, - 1...2 => 2, + 1..=2 => 2, _ => 3 }); } fn range_shadow_lit() { assert_eq!(2, match 1 { - 1...2 if false => 1, + 1..=2 if false => 1, 1 => 2, _ => 3 }); @@ -73,27 +73,27 @@ fn range_shadow_lit() { let x = 0; assert_eq!(2, match x+1 { 0 => 0, - 1...2 if false => 1, + 1..=2 if false => 1, 1 => 2, _ => 3 }); assert_eq!(2, match val() { - 1...2 if false => 1, + 1..=2 if false => 1, 1 => 2, _ => 3 }); assert_eq!(2, match CONST { 0 => 0, - 1...2 if false => 1, + 1..=2 if false => 1, 1 => 2, _ => 3 }); // ditto assert_eq!(3, match 3 { - 1...2 if false => 1, + 1..=2 if false => 1, 1 => 2, _ => 3 }); @@ -101,36 +101,36 @@ fn range_shadow_lit() { fn range_shadow_range() { assert_eq!(2, match 1 { - 0...2 if false => 1, - 1...3 => 2, + 0..=2 if false => 1, + 1..=3 => 2, _ => 3, }); let x = 0; assert_eq!(2, match x+1 { 100 => 0, - 0...2 if false => 1, - 1...3 => 2, + 0..=2 if false => 1, + 1..=3 => 2, _ => 3, }); assert_eq!(2, match val() { - 0...2 if false => 1, - 1...3 => 2, + 0..=2 if false => 1, + 1..=3 => 2, _ => 3, }); assert_eq!(2, match CONST { 100 => 0, - 0...2 if false => 1, - 1...3 => 2, + 0..=2 if false => 1, + 1..=3 => 2, _ => 3, }); // ditto assert_eq!(3, match 5 { - 0...2 if false => 1, - 1...3 => 2, + 0..=2 if false => 1, + 1..=3 => 2, _ => 3, }); } @@ -138,7 +138,7 @@ fn range_shadow_range() { fn multi_pats_shadow_lit() { assert_eq!(2, match 1 { 100 => 0, - 0 | 1...10 if false => 1, + 0 | 1..=10 if false => 1, 1 => 2, _ => 3, }); @@ -147,8 +147,8 @@ fn multi_pats_shadow_lit() { fn multi_pats_shadow_range() { assert_eq!(2, match 1 { 100 => 0, - 0 | 1...10 if false => 1, - 1...3 => 2, + 0 | 1..=10 if false => 1, + 1..=3 => 2, _ => 3, }); } @@ -157,7 +157,7 @@ fn lit_shadow_multi_pats() { assert_eq!(2, match 1 { 100 => 0, 1 if false => 1, - 0 | 1...10 => 2, + 0 | 1..=10 => 2, _ => 3, }); } @@ -165,8 +165,8 @@ fn lit_shadow_multi_pats() { fn range_shadow_multi_pats() { assert_eq!(2, match 1 { 100 => 0, - 1...3 if false => 1, - 0 | 1...10 => 2, + 1..=3 if false => 1, + 0 | 1..=10 => 2, _ => 3, }); } diff --git a/src/test/run-pass/issue-13867.rs b/src/test/run-pass/issue-13867.rs index e21070e2eaf..bc28dc54de6 100644 --- a/src/test/run-pass/issue-13867.rs +++ b/src/test/run-pass/issue-13867.rs @@ -19,14 +19,14 @@ enum Foo { fn main() { let r = match (Foo::FooNullary, 'a') { - (Foo::FooUint(..), 'a'...'z') => 1, + (Foo::FooUint(..), 'a'..='z') => 1, (Foo::FooNullary, 'x') => 2, _ => 0 }; assert_eq!(r, 0); let r = match (Foo::FooUint(0), 'a') { - (Foo::FooUint(1), 'a'...'z') => 1, + (Foo::FooUint(1), 'a'..='z') => 1, (Foo::FooUint(..), 'x') => 2, (Foo::FooNullary, 'a') => 3, _ => 0 @@ -34,7 +34,7 @@ fn main() { assert_eq!(r, 0); let r = match ('a', Foo::FooUint(0)) { - ('a'...'z', Foo::FooUint(1)) => 1, + ('a'..='z', Foo::FooUint(1)) => 1, ('x', Foo::FooUint(..)) => 2, ('a', Foo::FooNullary) => 3, _ => 0 @@ -42,15 +42,15 @@ fn main() { assert_eq!(r, 0); let r = match ('a', 'a') { - ('a'...'z', 'b') => 1, - ('x', 'a'...'z') => 2, + ('a'..='z', 'b') => 1, + ('x', 'a'..='z') => 2, _ => 0 }; assert_eq!(r, 0); let r = match ('a', 'a') { - ('a'...'z', 'b') => 1, - ('x', 'a'...'z') => 2, + ('a'..='z', 'b') => 1, + ('x', 'a'..='z') => 2, ('a', 'a') => 3, _ => 0 }; diff --git a/src/test/run-pass/issue-18060.rs b/src/test/run-pass/issue-18060.rs index d6c9a92ca02..322a3d8c9bb 100644 --- a/src/test/run-pass/issue-18060.rs +++ b/src/test/run-pass/issue-18060.rs @@ -11,7 +11,7 @@ // Regression test for #18060: match arms were matching in the wrong order. fn main() { - assert_eq!(2, match (1, 3) { (0, 2...5) => 1, (1, 3) => 2, (_, 2...5) => 3, (_, _) => 4 }); - assert_eq!(2, match (1, 3) { (1, 3) => 2, (_, 2...5) => 3, (_, _) => 4 }); - assert_eq!(2, match (1, 7) { (0, 2...5) => 1, (1, 7) => 2, (_, 2...5) => 3, (_, _) => 4 }); + assert_eq!(2, match (1, 3) { (0, 2..=5) => 1, (1, 3) => 2, (_, 2..=5) => 3, (_, _) => 4 }); + assert_eq!(2, match (1, 3) { (1, 3) => 2, (_, 2..=5) => 3, (_, _) => 4 }); + assert_eq!(2, match (1, 7) { (0, 2..=5) => 1, (1, 7) => 2, (_, 2..=5) => 3, (_, _) => 4 }); } diff --git a/src/test/run-pass/issue-18464.rs b/src/test/run-pass/issue-18464.rs index dff86bc1b45..f4faab5e468 100644 --- a/src/test/run-pass/issue-18464.rs +++ b/src/test/run-pass/issue-18464.rs @@ -15,7 +15,7 @@ const HIGH_RANGE: char = '9'; fn main() { match '5' { - LOW_RANGE...HIGH_RANGE => (), + LOW_RANGE..=HIGH_RANGE => (), _ => () }; } diff --git a/src/test/run-pass/issue-21475.rs b/src/test/run-pass/issue-21475.rs index 0666a1f133f..99839b56506 100644 --- a/src/test/run-pass/issue-21475.rs +++ b/src/test/run-pass/issue-21475.rs @@ -14,9 +14,9 @@ use m::{START, END}; fn main() { match 42 { - m::START...m::END => {}, - 0...m::END => {}, - m::START...59 => {}, + m::START..=m::END => {}, + 0..=m::END => {}, + m::START..=59 => {}, _ => {}, } } diff --git a/src/test/run-pass/issue-26251.rs b/src/test/run-pass/issue-26251.rs index 1e77d54fbf9..3735d36147d 100644 --- a/src/test/run-pass/issue-26251.rs +++ b/src/test/run-pass/issue-26251.rs @@ -12,9 +12,9 @@ fn main() { let x = 'a'; let y = match x { - 'a'...'b' if false => "one", + 'a'..='b' if false => "one", 'a' => "two", - 'a'...'b' => "three", + 'a'..='b' => "three", _ => panic!("what?"), }; diff --git a/src/test/run-pass/issue-35423.rs b/src/test/run-pass/issue-35423.rs index 35d0c305ed8..34cb2930db0 100644 --- a/src/test/run-pass/issue-35423.rs +++ b/src/test/run-pass/issue-35423.rs @@ -12,7 +12,7 @@ fn main () { let x = 4; match x { ref r if *r < 0 => println!("got negative num {} < 0", r), - e @ 1 ... 100 => println!("got number within range [1,100] {}", e), + e @ 1 ..= 100 => println!("got number within range [1,100] {}", e), _ => println!("no"), } } diff --git a/src/test/run-pass/issue-7222.rs b/src/test/run-pass/issue-7222.rs index 1bf343e23f0..3eb39ad6aad 100644 --- a/src/test/run-pass/issue-7222.rs +++ b/src/test/run-pass/issue-7222.rs @@ -14,7 +14,7 @@ pub fn main() { const FOO: f64 = 10.0; match 0.0 { - 0.0 ... FOO => (), + 0.0 ..= FOO => (), _ => () } } diff --git a/src/test/run-pass/macro-literal.rs b/src/test/run-pass/macro-literal.rs index 0bcda7bc144..6d5e8bc97c0 100644 --- a/src/test/run-pass/macro-literal.rs +++ b/src/test/run-pass/macro-literal.rs @@ -41,18 +41,18 @@ macro_rules! mtester_dbg { } macro_rules! catch_range { - ($s:literal ... $e:literal) => { - &format!("macro caught literal: {} ... {}", $s, $e) + ($s:literal ..= $e:literal) => { + &format!("macro caught literal: {} ..= {}", $s, $e) }; - (($s:expr) ... ($e:expr)) => { // Must use ')' before '...' - &format!("macro caught expr: {} ... {}", $s, $e) + (($s:expr) ..= ($e:expr)) => { // Must use ')' before '..=' + &format!("macro caught expr: {} ..= {}", $s, $e) }; } macro_rules! pat_match { - ($s:literal ... $e:literal) => { + ($s:literal ..= $e:literal) => { match 3 { - $s ... $e => "literal, in range", + $s ..= $e => "literal, in range", _ => "literal, other", } }; @@ -115,22 +115,22 @@ pub fn main() { assert_eq!(mtester!('c'), "macro caught literal: c"); assert_eq!(mtester!(-1.2), "macro caught literal: -1.2"); assert_eq!(two_negative_literals!(-2 -3), "macro caught literals: -2, -3"); - assert_eq!(catch_range!(2 ... 3), "macro caught literal: 2 ... 3"); + assert_eq!(catch_range!(2 ..= 3), "macro caught literal: 2 ..= 3"); assert_eq!(match_attr!(#[attr] 1), "attr matched literal"); assert_eq!(test_user!(10, 20), "literal"); assert_eq!(mtester!(false), "macro caught literal: false"); assert_eq!(mtester!(true), "macro caught literal: true"); match_produced_attr!("a"); let _a = LiteralProduced; - assert_eq!(pat_match!(1 ... 3), "literal, in range"); - assert_eq!(pat_match!(4 ... 6), "literal, other"); + assert_eq!(pat_match!(1 ..= 3), "literal, in range"); + assert_eq!(pat_match!(4 ..= 6), "literal, other"); // Cases where 'expr' catches assert_eq!(mtester!((-1.2)), "macro caught expr: -1.2"); assert_eq!(only_expr!(-1.2), "macro caught expr: -1.2"); assert_eq!(mtester!((1 + 3)), "macro caught expr: 4"); assert_eq!(mtester_dbg!(()), "macro caught expr: ()"); - assert_eq!(catch_range!((1 + 1) ... (2 + 2)), "macro caught expr: 2 ... 4"); + assert_eq!(catch_range!((1 + 1) ..= (2 + 2)), "macro caught expr: 2 ..= 4"); assert_eq!(match_attr!(#[attr] (1 + 2)), "attr matched expr"); assert_eq!(test_user!(10, (20 + 2)), "expr"); diff --git a/src/test/run-pass/match-range-infer.rs b/src/test/run-pass/match-range-infer.rs index 74f513ef081..cf07345d343 100644 --- a/src/test/run-pass/match-range-infer.rs +++ b/src/test/run-pass/match-range-infer.rs @@ -12,15 +12,15 @@ pub fn main() { match 1 { - 1 ... 3 => {} + 1 ..= 3 => {} _ => panic!("should match range") } match 1 { - 1 ... 3u16 => {} + 1 ..= 3u16 => {} _ => panic!("should match range with inferred start type") } match 1 { - 1u16 ... 3 => {} + 1u16 ..= 3 => {} _ => panic!("should match range with inferred end type") } } diff --git a/src/test/run-pass/match-range-static.rs b/src/test/run-pass/match-range-static.rs index 9aafcda1b02..b63ca7defd6 100644 --- a/src/test/run-pass/match-range-static.rs +++ b/src/test/run-pass/match-range-static.rs @@ -15,7 +15,7 @@ const e: isize = 42; pub fn main() { match 7 { - s...e => (), + s..=e => (), _ => (), } } diff --git a/src/test/run-pass/match-range.rs b/src/test/run-pass/match-range.rs index cf695a77ce1..859edb80a07 100644 --- a/src/test/run-pass/match-range.rs +++ b/src/test/run-pass/match-range.rs @@ -12,7 +12,7 @@ pub fn main() { match 5_usize { - 1_usize...5_usize => {} + 1_usize..=5_usize => {} _ => panic!("should match range"), } match 1_usize { @@ -20,7 +20,7 @@ pub fn main() { _ => panic!("should match range start"), } match 5_usize { - 6_usize...7_usize => panic!("shouldn't match range"), + 6_usize..=7_usize => panic!("shouldn't match range"), _ => {} } match 7_usize { @@ -29,23 +29,23 @@ pub fn main() { } match 5_usize { 1_usize => panic!("should match non-first range"), - 2_usize...6_usize => {} + 2_usize..=6_usize => {} _ => panic!("math is broken") } match 'c' { - 'a'...'z' => {} + 'a'..='z' => {} _ => panic!("should suppport char ranges") } match -3 { - -7...5 => {} + -7..=5 => {} _ => panic!("should match signed range") } match 3.0f64 { - 1.0...5.0 => {} + 1.0..=5.0 => {} _ => panic!("should match float range") } match -1.5f64 { - -3.6...3.6 => {} + -3.6..=3.6 => {} _ => panic!("should match negative float range") } match 3.5 { diff --git a/src/test/run-pass/rfc-2005-default-binding-mode/range.rs b/src/test/run-pass/rfc-2005-default-binding-mode/range.rs index 2292d97eaf4..f38bd2de869 100644 --- a/src/test/run-pass/rfc-2005-default-binding-mode/range.rs +++ b/src/test/run-pass/rfc-2005-default-binding-mode/range.rs @@ -11,8 +11,8 @@ pub fn main() { let i = 5; match &&&&i { - 1 ... 3 => panic!(), - 3 ... 8 => {}, + 1 ..= 3 => panic!(), + 3 ..= 8 => {}, _ => panic!(), } } diff --git a/src/test/ui/check_match/issue-43253.rs b/src/test/ui/check_match/issue-43253.rs index a01ebb768b4..aace8c0c02b 100644 --- a/src/test/ui/check_match/issue-43253.rs +++ b/src/test/ui/check_match/issue-43253.rs @@ -23,13 +23,13 @@ fn main() { match 10 { 1..10 => {}, - 9...10 => {}, + 9..=10 => {}, _ => {}, } match 10 { 1..10 => {}, - 10...10 => {}, + 10..=10 => {}, _ => {}, } @@ -42,13 +42,13 @@ fn main() { match 10 { 1..10 => {}, - 8...9 => {}, + 8..=9 => {}, _ => {}, } match 10 { 1..10 => {}, - 9...9 => {}, + 9..=9 => {}, _ => {}, } } diff --git a/src/test/ui/check_match/issue-43253.stderr b/src/test/ui/check_match/issue-43253.stderr index 111f4e44ee9..2af6a2a6368 100644 --- a/src/test/ui/check_match/issue-43253.stderr +++ b/src/test/ui/check_match/issue-43253.stderr @@ -13,12 +13,12 @@ LL | #![warn(unreachable_patterns)] warning: unreachable pattern --> $DIR/issue-43253.rs:45:9 | -LL | 8...9 => {}, +LL | 8..=9 => {}, | ^^^^^ warning: unreachable pattern --> $DIR/issue-43253.rs:51:9 | -LL | 9...9 => {}, +LL | 9..=9 => {}, | ^^^^^ diff --git a/src/test/ui/const-eval/const_signed_pat.rs b/src/test/ui/const-eval/const_signed_pat.rs index f53d6f3fa0a..008ebf13c63 100644 --- a/src/test/ui/const-eval/const_signed_pat.rs +++ b/src/test/ui/const-eval/const_signed_pat.rs @@ -13,7 +13,7 @@ fn main() { const MIN: i8 = -5; match 5i8 { - MIN...-1 => {}, + MIN..=-1 => {}, _ => {}, } } diff --git a/src/test/ui/const-eval/ref_to_int_match.rs b/src/test/ui/const-eval/ref_to_int_match.rs index 4c5fc6c3797..8ad7f11f0ce 100644 --- a/src/test/ui/const-eval/ref_to_int_match.rs +++ b/src/test/ui/const-eval/ref_to_int_match.rs @@ -11,8 +11,8 @@ fn main() { let n: Int = 40; match n { - 0...10 => {}, - 10...BAR => {}, //~ ERROR lower range bound must be less than or equal to upper + 0..=10 => {}, + 10..=BAR => {}, //~ ERROR lower range bound must be less than or equal to upper _ => {}, } } diff --git a/src/test/ui/const-eval/ref_to_int_match.stderr b/src/test/ui/const-eval/ref_to_int_match.stderr index eef7b6df252..64ea57702d7 100644 --- a/src/test/ui/const-eval/ref_to_int_match.stderr +++ b/src/test/ui/const-eval/ref_to_int_match.stderr @@ -1,7 +1,7 @@ error[E0030]: lower range bound must be less than or equal to upper --> $DIR/ref_to_int_match.rs:15:9 | -LL | 10...BAR => {}, //~ ERROR lower range bound must be less than or equal to upper +LL | 10..=BAR => {}, //~ ERROR lower range bound must be less than or equal to upper | ^^ lower bound larger than upper bound error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0029-teach.rs b/src/test/ui/error-codes/E0029-teach.rs index 1bc2c2d58b1..328c46311af 100644 --- a/src/test/ui/error-codes/E0029-teach.rs +++ b/src/test/ui/error-codes/E0029-teach.rs @@ -14,7 +14,7 @@ fn main() { let s = "hoho"; match s { - "hello" ... "world" => {} + "hello" ..= "world" => {} //~^ ERROR only char and numeric types are allowed in range patterns _ => {} } diff --git a/src/test/ui/error-codes/E0029-teach.stderr b/src/test/ui/error-codes/E0029-teach.stderr index 4bb71f68a98..bb4fac9a4cb 100644 --- a/src/test/ui/error-codes/E0029-teach.stderr +++ b/src/test/ui/error-codes/E0029-teach.stderr @@ -1,7 +1,7 @@ error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/E0029-teach.rs:17:9 | -LL | "hello" ... "world" => {} +LL | "hello" ..= "world" => {} | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types | = note: start type: &'static str diff --git a/src/test/ui/error-codes/E0029.rs b/src/test/ui/error-codes/E0029.rs index 29b6fe44113..c89b4f5b377 100644 --- a/src/test/ui/error-codes/E0029.rs +++ b/src/test/ui/error-codes/E0029.rs @@ -12,7 +12,7 @@ fn main() { let s = "hoho"; match s { - "hello" ... "world" => {} + "hello" ..= "world" => {} //~^ ERROR only char and numeric types are allowed in range patterns _ => {} } diff --git a/src/test/ui/error-codes/E0029.stderr b/src/test/ui/error-codes/E0029.stderr index bcdfa387111..d25666f9cf8 100644 --- a/src/test/ui/error-codes/E0029.stderr +++ b/src/test/ui/error-codes/E0029.stderr @@ -1,7 +1,7 @@ error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/E0029.rs:15:9 | -LL | "hello" ... "world" => {} +LL | "hello" ..= "world" => {} | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types | = note: start type: &'static str diff --git a/src/test/ui/error-codes/E0030-teach.rs b/src/test/ui/error-codes/E0030-teach.rs index 2af32eda62b..cf860cea24c 100644 --- a/src/test/ui/error-codes/E0030-teach.rs +++ b/src/test/ui/error-codes/E0030-teach.rs @@ -12,7 +12,7 @@ fn main() { match 5u32 { - 1000 ... 5 => {} + 1000 ..= 5 => {} //~^ ERROR lower range bound must be less than or equal to upper } } diff --git a/src/test/ui/error-codes/E0030-teach.stderr b/src/test/ui/error-codes/E0030-teach.stderr index 8b262d5b296..2a7243a9569 100644 --- a/src/test/ui/error-codes/E0030-teach.stderr +++ b/src/test/ui/error-codes/E0030-teach.stderr @@ -1,7 +1,7 @@ error[E0030]: lower range bound must be less than or equal to upper --> $DIR/E0030-teach.rs:15:9 | -LL | 1000 ... 5 => {} +LL | 1000 ..= 5 => {} | ^^^^ lower bound larger than upper bound | = note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. diff --git a/src/test/ui/error-codes/E0030.rs b/src/test/ui/error-codes/E0030.rs index ef3bded4bef..e147dd932b0 100644 --- a/src/test/ui/error-codes/E0030.rs +++ b/src/test/ui/error-codes/E0030.rs @@ -11,7 +11,7 @@ fn main() { match 5u32 { - 1000 ... 5 => {} + 1000 ..= 5 => {} //~^ ERROR lower range bound must be less than or equal to upper } } diff --git a/src/test/ui/error-codes/E0030.stderr b/src/test/ui/error-codes/E0030.stderr index 0949cfb50b6..020655ee45b 100644 --- a/src/test/ui/error-codes/E0030.stderr +++ b/src/test/ui/error-codes/E0030.stderr @@ -1,7 +1,7 @@ error[E0030]: lower range bound must be less than or equal to upper --> $DIR/E0030.rs:14:9 | -LL | 1000 ... 5 => {} +LL | 1000 ..= 5 => {} | ^^^^ lower bound larger than upper bound error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0308-4.rs b/src/test/ui/error-codes/E0308-4.rs index bb4cd143416..106c55817c1 100644 --- a/src/test/ui/error-codes/E0308-4.rs +++ b/src/test/ui/error-codes/E0308-4.rs @@ -11,7 +11,7 @@ fn main() { let x = 1u8; match x { - 0u8...3i8 => (), //~ ERROR E0308 + 0u8..=3i8 => (), //~ ERROR E0308 _ => () } } diff --git a/src/test/ui/error-codes/E0308-4.stderr b/src/test/ui/error-codes/E0308-4.stderr index 31875349bac..8943c7332e9 100644 --- a/src/test/ui/error-codes/E0308-4.stderr +++ b/src/test/ui/error-codes/E0308-4.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types --> $DIR/E0308-4.rs:14:9 | -LL | 0u8...3i8 => (), //~ ERROR E0308 +LL | 0u8..=3i8 => (), //~ ERROR E0308 | ^^^^^^^^^ expected u8, found i8 error: aborting due to previous error