placate clippy

This commit is contained in:
Connor Skees 2020-11-16 03:25:55 -05:00
parent 27eeaeef08
commit f17a1e6da2
9 changed files with 25 additions and 26 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -95,7 +95,7 @@ impl<'a> Parser<'a> {
if kind == '!'
|| kind == '%'
|| kind == '&'
|| (kind >= '*' && kind <= '~')
|| ('*'..='~').contains(&kind)
|| kind as u32 >= 0x0080
{
buf.push(kind);

View File

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

View File

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