diff --git a/src/builtin/functions/meta.rs b/src/builtin/functions/meta.rs index 7ad6e34..2190701 100644 --- a/src/builtin/functions/meta.rs +++ b/src/builtin/functions/meta.rs @@ -223,9 +223,10 @@ pub(crate) fn content_exists(args: CallArgs, parser: &mut Parser<'_>) -> SassRes )) } -#[allow(dead_code, unused_mut, unused_variables)] +#[allow(unused_variables)] pub(crate) fn keywords(args: CallArgs, parser: &mut Parser<'_>) -> SassResult { args.max_args(1)?; + drop(args); todo!("builtin function `keywords` blocked on better handling of call args") } diff --git a/src/builtin/modules/mod.rs b/src/builtin/modules/mod.rs index 45bd3ca..f32917f 100644 --- a/src/builtin/modules/mod.rs +++ b/src/builtin/modules/mod.rs @@ -32,7 +32,7 @@ pub(crate) struct Module { impl Module { pub fn get_var(&self, name: Spanned) -> SassResult<&Value> { match self.vars.get(&name.node) { - Some(v) => Ok(&v), + Some(v) => Ok(v), None => Err(("Undefined variable.", name.span).into()), } } diff --git a/src/parse/mod.rs b/src/parse/mod.rs index d63cc2d..7e77032 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -9,7 +9,10 @@ use crate::{ media::MediaRule, AtRuleKind, Content, SupportsRule, UnknownAtRule, }, - builtin::modules::*, + builtin::modules::{ + declare_module_color, declare_module_list, declare_module_map, declare_module_math, + declare_module_meta, declare_module_selector, declare_module_string, Module, + }, error::SassResult, scope::{Scope, Scopes}, selector::{ @@ -110,6 +113,7 @@ impl<'a> Parser<'a> { /// Returns any multiline comments that may have been found /// while loading modules + #[allow(clippy::eval_order_dependence)] fn load_modules(&mut self) -> SassResult> { let mut comments = Vec::new(); @@ -142,8 +146,7 @@ impl<'a> Parser<'a> { let quote = match self.toks.next() { Some(Token { kind: q @ '"', .. }) | Some(Token { kind: q @ '\'', .. }) => q, - Some(..) => todo!(), - None => todo!(), + Some(..) | None => todo!(), }; let Spanned { node: module, span } = self.parse_quoted_string(quote)?; @@ -183,31 +186,31 @@ impl<'a> Parser<'a> { match module.as_ref() { "sass:color" => self.modules.insert( - module_name.unwrap_or("color".to_owned()), + module_name.unwrap_or_else(|| "color".to_owned()), declare_module_color(), ), "sass:list" => self.modules.insert( - module_name.unwrap_or("list".to_owned()), + module_name.unwrap_or_else(|| "list".to_owned()), declare_module_list(), ), "sass:map" => self.modules.insert( - module_name.unwrap_or("map".to_owned()), + module_name.unwrap_or_else(|| "map".to_owned()), declare_module_map(), ), "sass:math" => self.modules.insert( - module_name.unwrap_or("math".to_owned()), + module_name.unwrap_or_else(|| "math".to_owned()), declare_module_math(), ), "sass:meta" => self.modules.insert( - module_name.unwrap_or("meta".to_owned()), + module_name.unwrap_or_else(|| "meta".to_owned()), declare_module_meta(), ), "sass:selector" => self.modules.insert( - module_name.unwrap_or("selector".to_owned()), + module_name.unwrap_or_else(|| "selector".to_owned()), declare_module_selector(), ), "sass:string" => self.modules.insert( - module_name.unwrap_or("string".to_owned()), + module_name.unwrap_or_else(|| "string".to_owned()), declare_module_string(), ), _ => todo!("@use not yet implemented"), diff --git a/src/parse/value/parse.rs b/src/parse/value/parse.rs index 48ed8f8..be1ce79 100644 --- a/src/parse/value/parse.rs +++ b/src/parse/value/parse.rs @@ -207,6 +207,7 @@ impl<'a> Parser<'a> { .parse_value(in_paren) } + #[allow(clippy::eval_order_dependence)] fn parse_module_item( &mut self, module: &str, @@ -224,7 +225,10 @@ impl<'a> Parser<'a> { let value = self .modules .get(module) - .ok_or((format!("There is no module with the namespace \"{}\".", module), module_span))? + .ok_or(( + format!("There is no module with the namespace \"{}\".", module), + module_span, + ))? .get_var(var)?; HigherIntermediateValue::Literal(value.clone()) } else { @@ -235,7 +239,10 @@ impl<'a> Parser<'a> { let function = self .modules .get(module) - .ok_or((format!("There is no module with the namespace \"{}\".", module), module_span))? + .ok_or(( + format!("There is no module with the namespace \"{}\".", module), + module_span, + ))? .get_fn(fn_name.node) .ok_or(("Undefined function.", fn_name.span))?; @@ -251,10 +258,6 @@ impl<'a> Parser<'a> { .span(module_span)) } - // fn parse_module_fn_call(&mut self, name: &str) -> SassResult> { - - // } - fn parse_ident_value(&mut self) -> SassResult> { let Spanned { node: mut s, span } = self.parse_identifier()?; diff --git a/tests/use.rs b/tests/use.rs index 07072ba..b40a5d3 100644 --- a/tests/use.rs +++ b/tests/use.rs @@ -12,33 +12,27 @@ error!( ); error!( interpolation_in_as_identifier, - "@use \"sass:math\" as m#{a}th;", - "Error: expected \";\"." + "@use \"sass:math\" as m#{a}th;", "Error: expected \";\"." ); error!( use_as_quoted_string, - "@use \"sass:math\" as \"math\";", - "Error: Expected identifier." + "@use \"sass:math\" as \"math\";", "Error: Expected identifier." ); error!( use_as_missing_s, - "@use \"sass:math\" a math;", - "Error: expected \";\"." + "@use \"sass:math\" a math;", "Error: expected \";\"." ); error!( unknown_module_get_variable, - "a { color: foo.$bar; }", - "Error: There is no module with the namespace \"foo\"." + "a { color: foo.$bar; }", "Error: There is no module with the namespace \"foo\"." ); error!( unknown_module_get_function, - "a { color: foo.bar(); }", - "Error: There is no module with the namespace \"foo\"." + "a { color: foo.bar(); }", "Error: There is no module with the namespace \"foo\"." ); error!( unknown_function, - "@use \"sass:math\";\na { color: math.bar(); }", - "Error: Undefined function." + "@use \"sass:math\";\na { color: math.bar(); }", "Error: Undefined function." ); test!( use_as,