Skip to content

Commit 8dba582

Browse files
committed
Resolve unnested_or_patterns pedantic clippy lint
warning: unnested or-patterns --> src/parse.rs:387:17 | 387 | / Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\')) 388 | | | Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {} | |___________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 387 | Some((_, 'n' | 'r' | 't' | '\\' | '\'' | '"' | '0')) => {} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:392:17 | 392 | Some((newline, ch @ '\n')) | Some((newline, ch @ '\r')) => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 392 | Some((newline, ch @ ('\n' | '\r'))) => { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:450:17 | 450 | / Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\')) 451 | | | Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {} | |______________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 450 | Some((_, b'n' | b'r' | b't' | b'\\' | b'0' | b'\'' | b'"')) => {} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:452:17 | 452 | Some((newline, b @ b'\n')) | Some((newline, b @ b'\r')) => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 452 | Some((newline, b @ (b'\n' | b'\r'))) => { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:553:17 | 553 | / Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\')) 554 | | | Some((_, '\'')) | Some((_, '"')) => {} | |__________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 553 | Some((_, 'n' | 'r' | 't' | '\\' | '\'' | '"')) => {} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:560:17 | 560 | Some((newline, ch @ '\n')) | Some((newline, ch @ '\r')) => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 560 | Some((newline, ch @ ('\n' | '\r'))) => { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:580:13 | 580 | / Some(b'n') | Some(b'r') | Some(b't') | Some(b'\\') | Some(b'0') | Some(b'\'') 581 | | | Some(b'"') => true, | |________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 580 | Some(b'n' | b'r' | b't' | b'\\' | b'0' | b'\'' | b'"') => true, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:604:13 | 604 | Some('n') | Some('r') | Some('t') | Some('\\') | Some('0') | Some('\'') | Some('"') => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 604 | Some('n' | 'r' | 't' | '\\' | '0' | '\'' | '"') => { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: unnested or-patterns --> src/parse.rs:695:13 | 695 | / Some((_, b @ b' ')) | Some((_, b @ b'\t')) | Some((_, b @ b'\n')) 696 | | | Some((_, b @ b'\r')) => { | |__________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns help: nest the patterns | 695 | Some((_, b @ (b' ' | b'\t' | b'\n' | b'\r'))) => { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 parent e4be003 commit 8dba582

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/parse.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,11 @@ fn cooked_string(mut input: Cursor) -> Result<Cursor, Reject> {
384384
Some((_, 'x')) => {
385385
backslash_x_char(&mut chars)?;
386386
}
387-
Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\'))
388-
| Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {}
387+
Some((_, 'n' | 'r' | 't' | '\\' | '\'' | '"' | '0')) => {}
389388
Some((_, 'u')) => {
390389
backslash_u(&mut chars)?;
391390
}
392-
Some((newline, ch @ '\n')) | Some((newline, ch @ '\r')) => {
391+
Some((newline, ch @ ('\n' | '\r'))) => {
393392
input = input.advance(newline + 1);
394393
trailing_backslash(&mut input, ch as u8)?;
395394
chars = input.char_indices();
@@ -447,9 +446,8 @@ fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> {
447446
Some((_, b'x')) => {
448447
backslash_x_byte(&mut bytes)?;
449448
}
450-
Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\'))
451-
| Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {}
452-
Some((newline, b @ b'\n')) | Some((newline, b @ b'\r')) => {
449+
Some((_, b'n' | b'r' | b't' | b'\\' | b'0' | b'\'' | b'"')) => {}
450+
Some((newline, b @ (b'\n' | b'\r'))) => {
453451
input = input.advance(newline + 1);
454452
trailing_backslash(&mut input, b)?;
455453
bytes = input.bytes().enumerate();
@@ -550,14 +548,13 @@ fn cooked_c_string(mut input: Cursor) -> Result<Cursor, Reject> {
550548
Some((_, 'x')) => {
551549
backslash_x_nonzero(&mut chars)?;
552550
}
553-
Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\'))
554-
| Some((_, '\'')) | Some((_, '"')) => {}
551+
Some((_, 'n' | 'r' | 't' | '\\' | '\'' | '"')) => {}
555552
Some((_, 'u')) => {
556553
if backslash_u(&mut chars)? == '\0' {
557554
break;
558555
}
559556
}
560-
Some((newline, ch @ '\n')) | Some((newline, ch @ '\r')) => {
557+
Some((newline, ch @ ('\n' | '\r'))) => {
561558
input = input.advance(newline + 1);
562559
trailing_backslash(&mut input, ch as u8)?;
563560
chars = input.char_indices();
@@ -577,8 +574,7 @@ fn byte(input: Cursor) -> Result<Cursor, Reject> {
577574
let ok = match bytes.next().map(|(_, b)| b) {
578575
Some(b'\\') => match bytes.next().map(|(_, b)| b) {
579576
Some(b'x') => backslash_x_byte(&mut bytes).is_ok(),
580-
Some(b'n') | Some(b'r') | Some(b't') | Some(b'\\') | Some(b'0') | Some(b'\'')
581-
| Some(b'"') => true,
577+
Some(b'n' | b'r' | b't' | b'\\' | b'0' | b'\'' | b'"') => true,
582578
_ => false,
583579
},
584580
b => b.is_some(),
@@ -601,9 +597,7 @@ fn character(input: Cursor) -> Result<Cursor, Reject> {
601597
Some('\\') => match chars.next().map(|(_, ch)| ch) {
602598
Some('x') => backslash_x_char(&mut chars).is_ok(),
603599
Some('u') => backslash_u(&mut chars).is_ok(),
604-
Some('n') | Some('r') | Some('t') | Some('\\') | Some('0') | Some('\'') | Some('"') => {
605-
true
606-
}
600+
Some('n' | 'r' | 't' | '\\' | '0' | '\'' | '"') => true,
607601
_ => false,
608602
},
609603
ch => ch.is_some(),
@@ -692,8 +686,7 @@ fn trailing_backslash(input: &mut Cursor, mut last: u8) -> Result<(), Reject> {
692686
return Err(Reject);
693687
}
694688
match whitespace.next() {
695-
Some((_, b @ b' ')) | Some((_, b @ b'\t')) | Some((_, b @ b'\n'))
696-
| Some((_, b @ b'\r')) => {
689+
Some((_, b @ (b' ' | b'\t' | b'\n' | b'\r'))) => {
697690
last = b;
698691
}
699692
Some((offset, _)) => {

0 commit comments

Comments
 (0)