diff --git a/src/builtin/functions/color/hsl.rs b/src/builtin/functions/color/hsl.rs index 83b2543..f26d1ec 100644 --- a/src/builtin/functions/color/hsl.rs +++ b/src/builtin/functions/color/hsl.rs @@ -480,14 +480,15 @@ pub(crate) fn invert(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult< }; match args.get_err(0, "color")? { Value::Color(c) => Ok(Value::Color(Box::new( - c.invert(weight.unwrap_or(Number::one())), + c.invert(weight.unwrap_or_else(Number::one)), ))), Value::Dimension(Some(n), u, _) => { if weight.is_some() { - Err(( + return Err(( "Only one argument may be passed to the plain-CSS invert() function.", args.span(), - ))?; + ) + .into()); } Ok(Value::String( format!("invert({}{})", n, u), diff --git a/src/lib.rs b/src/lib.rs index cf0e540..e4ae280 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,6 +52,12 @@ grass input.scss clippy::single_match, clippy::float_arithmetic, clippy::unimplemented, + clippy::pattern_type_mismatch, + clippy::blanket_clippy_restriction_lints, + clippy::option_if_let_else, + clippy::panic_in_result_fn, + clippy::unwrap_in_result, + clippy::map_err_ignore, // temporarily allowed while under heavy development. // eventually these allows should be refactored away @@ -69,6 +75,7 @@ grass input.scss clippy::redundant_pub_crate, // the api is changing too often to allot this clippy::missing_errors_doc, + clippy::missing_const_for_fn, clippy::integer_arithmetic, clippy::string_add, diff --git a/src/parse/control_flow.rs b/src/parse/control_flow.rs index 308a764..7f85522 100644 --- a/src/parse/control_flow.rs +++ b/src/parse/control_flow.rs @@ -188,10 +188,7 @@ impl<'a> Parser<'a> { Err(..) => return false, }; ident.node.make_ascii_lowercase(); - let v = match ident.node.to_ascii_lowercase().as_str() { - "to" | "through" => true, - _ => false, - }; + let v = matches!(ident.node.to_ascii_lowercase().as_str(), "to" | "through"); toks.reset_cursor(); v } diff --git a/src/parse/ident.rs b/src/parse/ident.rs index bfe9af0..7a60bd0 100644 --- a/src/parse/ident.rs +++ b/src/parse/ident.rs @@ -307,9 +307,7 @@ impl<'a> Parser<'a> { self.toks.next(); } - if value == 0 - || (value >= 0xD800 && value <= 0xDFFF) - || value >= 0x0010_FFFF + if value == 0 || (0xD800..=0xDFFF).contains(&value) || value >= 0x0010_FFFF { s.push('\u{FFFD}'); } else { diff --git a/src/parse/media.rs b/src/parse/media.rs index 3a4eafd..d7df971 100644 --- a/src/parse/media.rs +++ b/src/parse/media.rs @@ -82,9 +82,8 @@ impl<'a> Parser<'a> { buf.push(':'); buf.push(' '); - let value = self.parse_value(false, &|toks| match toks.peek() { - Some(Token { kind: ')', .. }) => true, - _ => false, + let value = self.parse_value(false, &|toks| { + matches!(toks.peek(), Some(Token { kind: ')', .. })) })?; self.expect_char(')')?; diff --git a/src/parse/module.rs b/src/parse/module.rs index 04e44fc..bc14170 100644 --- a/src/parse/module.rs +++ b/src/parse/module.rs @@ -68,10 +68,10 @@ impl<'a> Parser<'a> { self.expect_char(':')?; self.whitespace_or_comment(); - let value = self.parse_value(false, &|toks| match toks.peek() { - Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. }) => true, - _ => false, - })?; + let value = self.parse_value( + false, + &|toks| matches!(toks.peek(), Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. })) + )?; config.insert(name.map_node(|n| n.into()), value)?; diff --git a/src/parse/value/css_function.rs b/src/parse/value/css_function.rs index c20b0c3..a8e8127 100644 --- a/src/parse/value/css_function.rs +++ b/src/parse/value/css_function.rs @@ -95,7 +95,7 @@ impl<'a> Parser<'a> { if kind == '!' || kind == '%' || kind == '&' - || (kind >= '*' && kind <= '~') + || ('*'..='~').contains(&kind) || kind as u32 >= 0x0080 { buf.push(kind); diff --git a/src/selector/parse.rs b/src/selector/parse.rs index 46f47dc..b8575ac 100644 --- a/src/selector/parse.rs +++ b/src/selector/parse.rs @@ -560,10 +560,10 @@ fn is_fake_pseudo_element(name: &str) -> bool { match name.as_bytes().first() { Some(b'a') | Some(b'A') => name.to_ascii_lowercase() == "after", Some(b'b') | Some(b'B') => name.to_ascii_lowercase() == "before", - Some(b'f') | Some(b'F') => match name.to_ascii_lowercase().as_str() { - "first-line" | "first-letter" => true, - _ => false, - }, + Some(b'f') | Some(b'F') => matches!( + name.to_ascii_lowercase().as_str(), + "first-line" | "first-letter" + ), _ => false, } } diff --git a/src/value/mod.rs b/src/value/mod.rs index 141c74e..f89a088 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -286,10 +286,7 @@ impl Value { } pub fn is_true(&self) -> bool { - match self { - Value::Null | Value::False => false, - _ => true, - } + !matches!(self, Value::Null | Value::False) } pub fn unquote(self) -> Self {