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).
This commit is contained in:
Zack M. Davis 2018-05-28 19:42:11 -07:00
parent 764232cb2a
commit 057715557b
65 changed files with 217 additions and 218 deletions

View File

@ -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,
}
}

View File

@ -64,7 +64,7 @@ impl<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> {
}
}
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<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> {
}
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<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> {
}
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!();
}

View File

@ -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,
}

View File

@ -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) => {

View File

@ -1230,7 +1230,7 @@ impl<T> [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<usize, usize>
@ -1268,7 +1268,7 @@ impl<T> [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> [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]

View File

@ -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!();
}

View File

@ -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 {

View File

@ -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));

View File

@ -1753,9 +1753,9 @@ impl<S: Semantics> IeeeFloat<S> {
} 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!(),
});
}

View File

@ -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('$');

View File

@ -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 => {}
}
```
"##,

View File

@ -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)

View File

@ -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)
}
}

View File

@ -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,
}
}

View File

@ -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!
_ => ()
}
```

View File

@ -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

View File

@ -1557,14 +1557,14 @@ impl<T: Iterator<Item=char>> Parser<T> {
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<T: Iterator<Item=char>> Parser<T> {
// 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<T: Iterator<Item=char>> Parser<T> {
// 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<T: Iterator<Item=char>> Parser<T> {
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<T: Iterator<Item=char>> Parser<T> {
'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<T: Iterator<Item=char>> Parser<T> {
'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),

View File

@ -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,
}
});

View File

@ -76,7 +76,7 @@ impl CodePoint {
#[inline]
pub fn from_u32(value: u32) -> Option<CodePoint> {
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<char> {
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
}
}

View File

@ -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!") },
/// }
/// ```

View File

@ -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;
}
_ => {

View File

@ -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)
}
}

View File

@ -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
};

View File

@ -215,7 +215,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result<Vec<
return Err("stack is empty".to_string());
}
}
':' | '#' | ' ' | '.' | '0'...'9' => {
':' | '#' | ' ' | '.' | '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<Vec<
'#' => 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<Vec<
(FormatStateFlags, ' ') => {
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<Vec<
(FormatStateWidth, '.') => {
*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 {

View File

@ -14,7 +14,7 @@ fn main() {
let _: <<A>::B>::C; //~ ERROR cannot find type `A` in this scope
let _ = <<A>::B>::C; //~ ERROR cannot find type `A` in this scope
let <<A>::B>::C; //~ ERROR cannot find type `A` in this scope
let 0 ... <<A>::B>::C; //~ ERROR cannot find type `A` in this scope
let 0 ..= <<A>::B>::C; //~ ERROR cannot find type `A` in this scope
//~^ ERROR only char and numeric types are allowed in range patterns
<<A>::B>::C; //~ ERROR cannot find type `A` in this scope
}

View File

@ -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"),
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -11,7 +11,7 @@
fn main() {
let x = 0;
match 1 {
0 ... x => {}
0 ..= x => {}
//~^ ERROR runtime values cannot be referenced in patterns
};
}

View File

@ -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() {}

View File

@ -29,6 +29,6 @@ fn main() {
match 10 {
<S as Tr>::A::f::<u8> => {}
//~^ ERROR expected unit struct/variant or constant, found method `<<S as Tr>::A>::f<u8>`
0 ... <S as Tr>::A::f::<u8> => {} //~ ERROR only char and numeric types are allowed in range
0 ..= <S as Tr>::A::f::<u8> => {} //~ ERROR only char and numeric types are allowed in range
}
}

View File

@ -9,10 +9,10 @@
// except according to those terms.
fn func((1, (Some(1), 2...3)): (isize, (Option<isize>, isize))) { }
fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, 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
}

View File

@ -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...

View File

@ -36,7 +36,7 @@ pub fn main() {
}
match 100 {
b'a' ... b'z' => {},
b'a' ..= b'z' => {},
_ => panic!()
}

View File

@ -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());

View File

@ -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,
});
}

View File

@ -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,
});
}

View File

@ -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
};

View File

@ -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 });
}

View File

@ -15,7 +15,7 @@ const HIGH_RANGE: char = '9';
fn main() {
match '5' {
LOW_RANGE...HIGH_RANGE => (),
LOW_RANGE..=HIGH_RANGE => (),
_ => ()
};
}

View File

@ -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 => {},
_ => {},
}
}

View File

@ -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?"),
};

View File

@ -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"),
}
}

View File

@ -14,7 +14,7 @@ pub fn main() {
const FOO: f64 = 10.0;
match 0.0 {
0.0 ... FOO => (),
0.0 ..= FOO => (),
_ => ()
}
}

View File

@ -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");

View File

@ -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")
}
}

View File

@ -15,7 +15,7 @@ const e: isize = 42;
pub fn main() {
match 7 {
s...e => (),
s..=e => (),
_ => (),
}
}

View File

@ -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 {

View File

@ -11,8 +11,8 @@
pub fn main() {
let i = 5;
match &&&&i {
1 ... 3 => panic!(),
3 ... 8 => {},
1 ..= 3 => panic!(),
3 ..= 8 => {},
_ => panic!(),
}
}

View File

@ -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 => {},
_ => {},
}
}

View File

@ -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 => {},
| ^^^^^

View File

@ -13,7 +13,7 @@
fn main() {
const MIN: i8 = -5;
match 5i8 {
MIN...-1 => {},
MIN..=-1 => {},
_ => {},
}
}

View File

@ -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
_ => {},
}
}

View File

@ -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

View File

@ -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
_ => {}
}

View File

@ -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

View File

@ -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
_ => {}
}

View File

@ -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

View File

@ -12,7 +12,7 @@
fn main() {
match 5u32 {
1000 ... 5 => {}
1000 ..= 5 => {}
//~^ ERROR lower range bound must be less than or equal to upper
}
}

View File

@ -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.

View File

@ -11,7 +11,7 @@
fn main() {
match 5u32 {
1000 ... 5 => {}
1000 ..= 5 => {}
//~^ ERROR lower range bound must be less than or equal to upper
}
}

View File

@ -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

View File

@ -11,7 +11,7 @@
fn main() {
let x = 1u8;
match x {
0u8...3i8 => (), //~ ERROR E0308
0u8..=3i8 => (), //~ ERROR E0308
_ => ()
}
}

View File

@ -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