Appeasing the clippy

This commit is contained in:
Chelsea Troy 2021-12-01 18:56:15 -06:00
parent f680ee3c24
commit b65a69f07e
2 changed files with 4 additions and 6 deletions

View file

@ -313,14 +313,14 @@ pub fn canonicalize_expr<'a>(
} else { } else {
// multiple chars is found // multiple chars is found
let error = roc_problem::can::RuntimeError::MultipleCharsInSingleQuote(region); let error = roc_problem::can::RuntimeError::MultipleCharsInSingleQuote(region);
let answer = Expr::RuntimeError(error.clone()); let answer = Expr::RuntimeError(error);
(answer, Output::default()) (answer, Output::default())
} }
} else { } else {
// no characters found // no characters found
let error = roc_problem::can::RuntimeError::EmptySingleQuote(region); let error = roc_problem::can::RuntimeError::EmptySingleQuote(region);
let answer = Expr::RuntimeError(error.clone()); let answer = Expr::RuntimeError(error);
(answer, Output::default()) (answer, Output::default())
} }

View file

@ -66,8 +66,7 @@ pub fn parse_single_quote<'a>() -> impl Parser<'a, &'a str, EString<'a>> {
match state.bytes.first() { match state.bytes.first() {
Some(&ch) => { Some(&ch) => {
state = advance_state!(state, 1)?; state = advance_state!(state, 1)?;
if ch == b'n' || ch == b'r' || ch == b't' || ch == b'\'' || ch == b'\\' { if (ch == b'n' || ch == b'r' || ch == b't' || ch == b'\'' || ch == b'\\') && (state.bytes.first() == Some(&b'\'')) {
if state.bytes.first() == Some(&b'\'') {
state = advance_state!(state, 1)?; state = advance_state!(state, 1)?;
// since we checked the current char between the single quotes we // since we checked the current char between the single quotes we
// know they are valid UTF-8, allowing us to use 'from_u32_unchecked' // know they are valid UTF-8, allowing us to use 'from_u32_unchecked'
@ -79,7 +78,6 @@ pub fn parse_single_quote<'a>() -> impl Parser<'a, &'a str, EString<'a>> {
state, state,
)); ));
} }
}
// invalid error, backslah escaping something we do not recognize // invalid error, backslah escaping something we do not recognize
return Err(( return Err((
NoProgress, NoProgress,
@ -145,7 +143,7 @@ pub fn parse_single_quote<'a>() -> impl Parser<'a, &'a str, EString<'a>> {
state = advance_state!(state, end_index)?; state = advance_state!(state, end_index)?;
match std::str::from_utf8(raw_bytes) { match std::str::from_utf8(raw_bytes) {
Ok(string) => { Ok(string) => {
return Ok((MadeProgress, string, state)); Ok((MadeProgress, string, state))
} }
Err(_) => { Err(_) => {
// invalid UTF-8 // invalid UTF-8