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")? { match args.get_err(0, "color")? {
Value::Color(c) => Ok(Value::Color(Box::new( 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, _) => { Value::Dimension(Some(n), u, _) => {
if weight.is_some() { if weight.is_some() {
Err(( return Err((
"Only one argument may be passed to the plain-CSS invert() function.", "Only one argument may be passed to the plain-CSS invert() function.",
args.span(), args.span(),
))?; )
.into());
} }
Ok(Value::String( Ok(Value::String(
format!("invert({}{})", n, u), format!("invert({}{})", n, u),

View File

@ -52,6 +52,12 @@ grass input.scss
clippy::single_match, clippy::single_match,
clippy::float_arithmetic, clippy::float_arithmetic,
clippy::unimplemented, 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. // temporarily allowed while under heavy development.
// eventually these allows should be refactored away // eventually these allows should be refactored away
@ -69,6 +75,7 @@ grass input.scss
clippy::redundant_pub_crate, clippy::redundant_pub_crate,
// the api is changing too often to allot this // the api is changing too often to allot this
clippy::missing_errors_doc, clippy::missing_errors_doc,
clippy::missing_const_for_fn,
clippy::integer_arithmetic, clippy::integer_arithmetic,
clippy::string_add, clippy::string_add,

View File

@ -188,10 +188,7 @@ impl<'a> Parser<'a> {
Err(..) => return false, Err(..) => return false,
}; };
ident.node.make_ascii_lowercase(); ident.node.make_ascii_lowercase();
let v = match ident.node.to_ascii_lowercase().as_str() { let v = matches!(ident.node.to_ascii_lowercase().as_str(), "to" | "through");
"to" | "through" => true,
_ => false,
};
toks.reset_cursor(); toks.reset_cursor();
v v
} }

View File

@ -307,9 +307,7 @@ impl<'a> Parser<'a> {
self.toks.next(); self.toks.next();
} }
if value == 0 if value == 0 || (0xD800..=0xDFFF).contains(&value) || value >= 0x0010_FFFF
|| (value >= 0xD800 && value <= 0xDFFF)
|| value >= 0x0010_FFFF
{ {
s.push('\u{FFFD}'); s.push('\u{FFFD}');
} else { } else {

View File

@ -82,9 +82,8 @@ impl<'a> Parser<'a> {
buf.push(':'); buf.push(':');
buf.push(' '); buf.push(' ');
let value = self.parse_value(false, &|toks| match toks.peek() { let value = self.parse_value(false, &|toks| {
Some(Token { kind: ')', .. }) => true, matches!(toks.peek(), Some(Token { kind: ')', .. }))
_ => false,
})?; })?;
self.expect_char(')')?; self.expect_char(')')?;

View File

@ -68,10 +68,10 @@ impl<'a> Parser<'a> {
self.expect_char(':')?; self.expect_char(':')?;
self.whitespace_or_comment(); self.whitespace_or_comment();
let value = self.parse_value(false, &|toks| match toks.peek() { let value = self.parse_value(
Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. }) => true, false,
_ => false, &|toks| matches!(toks.peek(), Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. }))
})?; )?;
config.insert(name.map_node(|n| n.into()), value)?; config.insert(name.map_node(|n| n.into()), value)?;

View File

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

View File

@ -560,10 +560,10 @@ fn is_fake_pseudo_element(name: &str) -> bool {
match name.as_bytes().first() { match name.as_bytes().first() {
Some(b'a') | Some(b'A') => name.to_ascii_lowercase() == "after", Some(b'a') | Some(b'A') => name.to_ascii_lowercase() == "after",
Some(b'b') | Some(b'B') => name.to_ascii_lowercase() == "before", Some(b'b') | Some(b'B') => name.to_ascii_lowercase() == "before",
Some(b'f') | Some(b'F') => match name.to_ascii_lowercase().as_str() { Some(b'f') | Some(b'F') => matches!(
"first-line" | "first-letter" => true, name.to_ascii_lowercase().as_str(),
_ => false, "first-line" | "first-letter"
}, ),
_ => false, _ => false,
} }
} }

View File

@ -286,10 +286,7 @@ impl Value {
} }
pub fn is_true(&self) -> bool { pub fn is_true(&self) -> bool {
match self { !matches!(self, Value::Null | Value::False)
Value::Null | Value::False => false,
_ => true,
}
} }
pub fn unquote(self) -> Self { pub fn unquote(self) -> Self {