Skip to content

Commit

Permalink
use cargo fix to automatically fix range pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji authored and alexcrichton committed Oct 8, 2019
1 parent a7608b5 commit 6ee533b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<'a> fmt::Display for Demangle<'a> {
if escape.starts_with('u') {
let digits = &escape[1..];
let all_lower_hex = digits.chars().all(|c| match c {
'0'...'9' | 'a'...'f' => true,
'0'..='9' | 'a'..='f' => true,
_ => false,
});
let c = u32::from_str_radix(digits, 16)
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn demangle(mut s: &str) -> Demangle {
if let Some(i) = s.find(llvm) {
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,
});

Expand Down Expand Up @@ -160,18 +160,18 @@ fn is_symbol_like(s: &str) -> bool {
// Copied from the documentation of `char::is_ascii_alphanumeric`
fn is_ascii_alphanumeric(c: char) -> bool {
match c {
'\u{0041}'...'\u{005A}' | '\u{0061}'...'\u{007A}' | '\u{0030}'...'\u{0039}' => true,
'\u{0041}'..='\u{005A}' | '\u{0061}'..='\u{007A}' | '\u{0030}'..='\u{0039}' => true,
_ => false,
}
}

// Copied from the documentation of `char::is_ascii_punctuation`
fn is_ascii_punctuation(c: char) -> bool {
match c {
'\u{0021}'...'\u{002F}'
| '\u{003A}'...'\u{0040}'
| '\u{005B}'...'\u{0060}'
| '\u{007B}'...'\u{007E}' => true,
'\u{0021}'..='\u{002F}'
| '\u{003A}'..='\u{0040}'
| '\u{005B}'..='\u{0060}'
| '\u{007B}'..='\u{007E}' => true,
_ => false,
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn demangle(s: &str) -> Result<(Demangle, &str), Invalid> {

// Paths always start with uppercase characters.
match inner.as_bytes()[0] {
b'A'...b'Z' => {}
b'A'..=b'Z' => {}
_ => return Err(Invalid),
}

Expand All @@ -50,7 +50,7 @@ pub fn demangle(s: &str) -> Result<(Demangle, &str), Invalid> {

// Instantiating crate (paths always start with uppercase characters).
match parser.sym.as_bytes().get(parser.next) {
Some(&b'A'...b'Z') => {
Some(&(b'A'..=b'Z')) => {
try!(parser.skip_path());
}
_ => {}
Expand Down Expand Up @@ -159,8 +159,8 @@ impl<'s> Ident<'s> {
let t = min(max(k.saturating_sub(bias), t_min), t_max);

let d = match punycode_bytes.next() {
Some(d @ b'a'...b'z') => d - b'a',
Some(d @ b'0'...b'9') => 26 + (d - b'0'),
Some(d @ b'a'..=b'z') => d - b'a',
Some(d @ b'0'..=b'9') => 26 + (d - b'0'),
_ => return Err(()),
};
let d = d as usize;
Expand Down Expand Up @@ -295,7 +295,7 @@ impl<'s> Parser<'s> {
let start = self.next;
loop {
match try!(self.next()) {
b'0'...b'9' | b'a'...b'f' => {}
b'0'..=b'9' | b'a'..=b'f' => {}
b'_' => break,
_ => return Err(Invalid),
}
Expand All @@ -305,7 +305,7 @@ impl<'s> Parser<'s> {

fn digit_10(&mut self) -> Result<u8, Invalid> {
let d = match self.peek() {
Some(d @ b'0'...b'9') => d - b'0',
Some(d @ b'0'..=b'9') => d - b'0',
_ => return Err(Invalid),
};
self.next += 1;
Expand All @@ -314,9 +314,9 @@ impl<'s> Parser<'s> {

fn digit_62(&mut self) -> Result<u8, Invalid> {
let d = match self.peek() {
Some(d @ b'0'...b'9') => d - b'0',
Some(d @ b'a'...b'z') => 10 + (d - b'a'),
Some(d @ b'A'...b'Z') => 10 + 26 + (d - b'A'),
Some(d @ b'0'..=b'9') => d - b'0',
Some(d @ b'a'..=b'z') => 10 + (d - b'a'),
Some(d @ b'A'..=b'Z') => 10 + 26 + (d - b'A'),
_ => return Err(Invalid),
};
self.next += 1;
Expand Down Expand Up @@ -351,10 +351,10 @@ impl<'s> Parser<'s> {
fn namespace(&mut self) -> Result<Option<char>, Invalid> {
match try!(self.next()) {
// Special namespaces, like closures and shims.
ns @ b'A'...b'Z' => Ok(Some(ns as char)),
ns @ b'A'..=b'Z' => Ok(Some(ns as char)),

// Implementation-specific/unspecified namespaces.
b'a'...b'z' => Ok(None),
b'a'..=b'z' => Ok(None),

_ => Err(Invalid),
}
Expand Down

0 comments on commit 6ee533b

Please sign in to comment.