diff --git a/src/args.rs b/src/args.rs index e14ade4..b44b0a1 100644 --- a/src/args.rs +++ b/src/args.rs @@ -173,6 +173,7 @@ impl CallArgs { let len = self.len(); if len > max { let mut err = String::with_capacity(50); + #[allow(clippy::format_push_string)] err.push_str(&format!("Only {} argument", max)); if max != 1 { err.push('s'); diff --git a/src/common.rs b/src/common.rs index 7f5b037..2867ca1 100644 --- a/src/common.rs +++ b/src/common.rs @@ -172,7 +172,7 @@ pub(crate) fn unvendor(name: &str) -> &str { return name; } - if bytes.get(0_usize) != Some(&b'-') || bytes.get(1_usize) == Some(&b'-') { + if bytes.first() != Some(&b'-') || bytes.get(1_usize) == Some(&b'-') { return name; } diff --git a/src/interner.rs b/src/interner.rs index 7b17b89..c394b7f 100644 --- a/src/interner.rs +++ b/src/interner.rs @@ -24,9 +24,7 @@ impl InternedString { } pub fn resolve_ref<'a>(self) -> &'a str { - unsafe { - STRINGS.with(|interner| &(*(interner.as_ptr()).as_ref().unwrap().resolve(&self.0))) - } + unsafe { STRINGS.with(|interner| interner.as_ptr().as_ref().unwrap().resolve(&self.0)) } } } diff --git a/src/lib.rs b/src/lib.rs index 0ce9268..df3709f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,76 +23,38 @@ grass input.scss ``` */ -#![warn( - clippy::all, - clippy::restriction, - clippy::pedantic, - clippy::nursery, - clippy::cargo -)] +#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)] #![deny(missing_debug_implementations)] #![allow( - // explicit return makes some things look ugly - clippy::implicit_return, clippy::use_self, clippy::missing_docs_in_private_items, clippy::unreachable, - // this disallows binding as well, e.g. `v => ...` - clippy::wildcard_enum_match_arm, clippy::module_name_repetitions, - // it is sometimes useful to break up `impl`s - clippy::multiple_inherent_impl, // filter isn't fallible clippy::manual_filter_map, - clippy::else_if_without_else, clippy::new_ret_no_self, renamed_and_removed_lints, clippy::unknown_clippy_lints, 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, - clippy::default_numeric_fallback, - clippy::if_then_some_else_none, - clippy::string_slice, - clippy::separated_literal_suffix, - clippy::non_ascii_literal, - clippy::same_name_method, - clippy::undocumented_unsafe_blocks, - clippy::exhaustive_structs, - clippy::single_char_lifetime_names, clippy::branches_sharing_code, + clippy::derive_partial_eq_without_eq, // temporarily allowed while under heavy development. // eventually these allows should be refactored away // to no longer be necessary - clippy::as_conversions, - clippy::todo, clippy::too_many_lines, - clippy::panic, - clippy::unwrap_used, - clippy::unwrap_used, clippy::cast_possible_truncation, clippy::single_match_else, - clippy::indexing_slicing, clippy::redundant_pub_crate, // the api is changing too often to allot this clippy::missing_errors_doc, clippy::missing_const_for_fn, clippy::multiple_crate_versions, - clippy::integer_arithmetic, - clippy::string_add, - clippy::get_unwrap, clippy::wrong_self_convention, clippy::items_after_statements, - clippy::shadow_reuse, - clippy::shadow_unrelated, // this is only available on nightly clippy::unnested_or_patterns, )] diff --git a/src/main.rs b/src/main.rs index 8a1de37..9b5927c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use grass::{from_path, from_string, Options, OutputStyle}; // TODO remove this arg_enum! { - #[derive(PartialEq, Debug)] + #[derive(Eq, PartialEq, Debug)] pub enum Style { Expanded, Compressed, @@ -18,7 +18,7 @@ arg_enum! { } arg_enum! { - #[derive(PartialEq, Debug)] + #[derive(Eq, PartialEq, Debug)] pub enum SourceMapUrls { Relative, Absolute, diff --git a/src/output.rs b/src/output.rs index 3fa99de..629a4f3 100644 --- a/src/output.rs +++ b/src/output.rs @@ -404,9 +404,10 @@ trait Formatter { } #[derive(Debug, Default)] -struct CompressedFormatter {} +struct CompressedFormatter; impl Formatter for CompressedFormatter { + #[allow(clippy::only_used_in_recursion)] fn write_css(&mut self, buf: &mut Vec, css: Css, map: &CodeMap) -> SassResult<()> { for block in css.blocks { match block { @@ -593,6 +594,7 @@ pub(crate) enum AtRuleContext { } impl Formatter for ExpandedFormatter { + #[allow(clippy::only_used_in_recursion)] fn write_css(&mut self, buf: &mut Vec, css: Css, map: &CodeMap) -> SassResult<()> { let padding = " ".repeat(self.nesting); self.nesting += 1; diff --git a/src/parse/ident.rs b/src/parse/ident.rs index 3a27ed4..17f5e42 100644 --- a/src/parse/ident.rs +++ b/src/parse/ident.rs @@ -118,11 +118,11 @@ impl<'a, 'b> Parser<'a, 'b> { } let c = std::char::from_u32(value).ok_or(("Invalid Unicode code point.", span))?; - if (identifier_start && is_name_start(c) && !c.is_digit(10)) + if (identifier_start && is_name_start(c) && !c.is_ascii_digit()) || (!identifier_start && is_name(c)) { Ok(c.to_string()) - } else if value <= 0x1F || value == 0x7F || (identifier_start && c.is_digit(10)) { + } else if value <= 0x1F || value == 0x7F || (identifier_start && c.is_ascii_digit()) { let mut buf = String::with_capacity(4); buf.push('\\'); if value > 0xF { diff --git a/src/parse/value/parse.rs b/src/parse/value/parse.rs index ca0caca..f5977b0 100644 --- a/src/parse/value/parse.rs +++ b/src/parse/value/parse.rs @@ -1330,6 +1330,7 @@ impl<'a, 'b: 'a, 'c> IntermediateValueIterator<'a, 'b, 'c> { Ok(()) } + #[allow(clippy::only_used_in_recursion)] fn single_value(&mut self, in_paren: bool) -> SassResult> { let next = self .next() diff --git a/src/selector/list.rs b/src/selector/list.rs index b00aa55..de893ba 100644 --- a/src/selector/list.rs +++ b/src/selector/list.rs @@ -274,10 +274,7 @@ fn flatten_vertically(iterable: Vec>) -> Vec { result.push(queue.pop_front().unwrap()); } - queues = queues - .into_iter() - .filter(|queue| !queue.is_empty()) - .collect(); + queues.retain(|queue| !queue.is_empty()); } result diff --git a/src/unit/mod.rs b/src/unit/mod.rs index d413dae..112c50b 100644 --- a/src/unit/mod.rs +++ b/src/unit/mod.rs @@ -196,7 +196,7 @@ impl Mul for Unit { Unit::Mul(u) => match rhs { Unit::Mul(u2) => { let mut unit1 = *u; - unit1.extend_from_slice(&*u2); + unit1.extend_from_slice(&u2); Unit::Mul(Box::new(unit1)) } Unit::Div(..) => todo!(), @@ -210,7 +210,7 @@ impl Mul for Unit { _ => match rhs { Unit::Mul(u2) => { let mut unit1 = vec![self]; - unit1.extend_from_slice(&*u2); + unit1.extend_from_slice(&u2); Unit::Mul(Box::new(unit1)) } Unit::Div(..) => todo!(), diff --git a/src/value/mod.rs b/src/value/mod.rs index fea0031..0162bdc 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -570,6 +570,7 @@ impl Value { .0) } + #[allow(clippy::only_used_in_recursion)] fn selector_string(self, span: Span) -> SassResult> { Ok(Some(match self { Value::String(text, ..) => text, diff --git a/src/value/number/mod.rs b/src/value/number/mod.rs index 7a38f4e..10d2e1b 100644 --- a/src/value/number/mod.rs +++ b/src/value/number/mod.rs @@ -141,8 +141,8 @@ impl Number { #[allow(clippy::cast_precision_loss)] pub fn as_float(self) -> Option { Some(match self { - Number::Small(n) => ((*n.numer() as f64) / (*n.denom() as f64)), - Number::Big(n) => ((n.numer().to_f64()?) / (n.denom().to_f64()?)), + Number::Small(n) => (*n.numer() as f64) / (*n.denom() as f64), + Number::Big(n) => (n.numer().to_f64()?) / (n.denom().to_f64()?), }) }