resolve clippy lints

This commit is contained in:
Connor Skees 2020-07-26 13:49:13 -04:00
parent ee57cda9c5
commit dbfa691505
5 changed files with 31 additions and 30 deletions

View File

@ -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<Value> {
args.max_args(1)?;
drop(args);
todo!("builtin function `keywords` blocked on better handling of call args")
}

View File

@ -32,7 +32,7 @@ pub(crate) struct Module {
impl Module {
pub fn get_var(&self, name: Spanned<Identifier>) -> SassResult<&Value> {
match self.vars.get(&name.node) {
Some(v) => Ok(&v),
Some(v) => Ok(v),
None => Err(("Undefined variable.", name.span).into()),
}
}

View File

@ -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<Vec<Stmt>> {
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"),

View File

@ -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<Spanned<IntermediateValue>> {
// }
fn parse_ident_value(&mut self) -> SassResult<Spanned<IntermediateValue>> {
let Spanned { node: mut s, span } = self.parse_identifier()?;

View File

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