resolve clippy lints
This commit is contained in:
parent
ee57cda9c5
commit
dbfa691505
@ -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> {
|
pub(crate) fn keywords(args: CallArgs, parser: &mut Parser<'_>) -> SassResult<Value> {
|
||||||
args.max_args(1)?;
|
args.max_args(1)?;
|
||||||
|
drop(args);
|
||||||
todo!("builtin function `keywords` blocked on better handling of call args")
|
todo!("builtin function `keywords` blocked on better handling of call args")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ pub(crate) struct Module {
|
|||||||
impl Module {
|
impl Module {
|
||||||
pub fn get_var(&self, name: Spanned<Identifier>) -> SassResult<&Value> {
|
pub fn get_var(&self, name: Spanned<Identifier>) -> SassResult<&Value> {
|
||||||
match self.vars.get(&name.node) {
|
match self.vars.get(&name.node) {
|
||||||
Some(v) => Ok(&v),
|
Some(v) => Ok(v),
|
||||||
None => Err(("Undefined variable.", name.span).into()),
|
None => Err(("Undefined variable.", name.span).into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,10 @@ use crate::{
|
|||||||
media::MediaRule,
|
media::MediaRule,
|
||||||
AtRuleKind, Content, SupportsRule, UnknownAtRule,
|
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,
|
error::SassResult,
|
||||||
scope::{Scope, Scopes},
|
scope::{Scope, Scopes},
|
||||||
selector::{
|
selector::{
|
||||||
@ -110,6 +113,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
/// Returns any multiline comments that may have been found
|
/// Returns any multiline comments that may have been found
|
||||||
/// while loading modules
|
/// while loading modules
|
||||||
|
#[allow(clippy::eval_order_dependence)]
|
||||||
fn load_modules(&mut self) -> SassResult<Vec<Stmt>> {
|
fn load_modules(&mut self) -> SassResult<Vec<Stmt>> {
|
||||||
let mut comments = Vec::new();
|
let mut comments = Vec::new();
|
||||||
|
|
||||||
@ -142,8 +146,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
let quote = match self.toks.next() {
|
let quote = match self.toks.next() {
|
||||||
Some(Token { kind: q @ '"', .. }) | Some(Token { kind: q @ '\'', .. }) => q,
|
Some(Token { kind: q @ '"', .. }) | Some(Token { kind: q @ '\'', .. }) => q,
|
||||||
Some(..) => todo!(),
|
Some(..) | None => todo!(),
|
||||||
None => todo!(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let Spanned { node: module, span } = self.parse_quoted_string(quote)?;
|
let Spanned { node: module, span } = self.parse_quoted_string(quote)?;
|
||||||
@ -183,31 +186,31 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
match module.as_ref() {
|
match module.as_ref() {
|
||||||
"sass:color" => self.modules.insert(
|
"sass:color" => self.modules.insert(
|
||||||
module_name.unwrap_or("color".to_owned()),
|
module_name.unwrap_or_else(|| "color".to_owned()),
|
||||||
declare_module_color(),
|
declare_module_color(),
|
||||||
),
|
),
|
||||||
"sass:list" => self.modules.insert(
|
"sass:list" => self.modules.insert(
|
||||||
module_name.unwrap_or("list".to_owned()),
|
module_name.unwrap_or_else(|| "list".to_owned()),
|
||||||
declare_module_list(),
|
declare_module_list(),
|
||||||
),
|
),
|
||||||
"sass:map" => self.modules.insert(
|
"sass:map" => self.modules.insert(
|
||||||
module_name.unwrap_or("map".to_owned()),
|
module_name.unwrap_or_else(|| "map".to_owned()),
|
||||||
declare_module_map(),
|
declare_module_map(),
|
||||||
),
|
),
|
||||||
"sass:math" => self.modules.insert(
|
"sass:math" => self.modules.insert(
|
||||||
module_name.unwrap_or("math".to_owned()),
|
module_name.unwrap_or_else(|| "math".to_owned()),
|
||||||
declare_module_math(),
|
declare_module_math(),
|
||||||
),
|
),
|
||||||
"sass:meta" => self.modules.insert(
|
"sass:meta" => self.modules.insert(
|
||||||
module_name.unwrap_or("meta".to_owned()),
|
module_name.unwrap_or_else(|| "meta".to_owned()),
|
||||||
declare_module_meta(),
|
declare_module_meta(),
|
||||||
),
|
),
|
||||||
"sass:selector" => self.modules.insert(
|
"sass:selector" => self.modules.insert(
|
||||||
module_name.unwrap_or("selector".to_owned()),
|
module_name.unwrap_or_else(|| "selector".to_owned()),
|
||||||
declare_module_selector(),
|
declare_module_selector(),
|
||||||
),
|
),
|
||||||
"sass:string" => self.modules.insert(
|
"sass:string" => self.modules.insert(
|
||||||
module_name.unwrap_or("string".to_owned()),
|
module_name.unwrap_or_else(|| "string".to_owned()),
|
||||||
declare_module_string(),
|
declare_module_string(),
|
||||||
),
|
),
|
||||||
_ => todo!("@use not yet implemented"),
|
_ => todo!("@use not yet implemented"),
|
||||||
|
@ -207,6 +207,7 @@ impl<'a> Parser<'a> {
|
|||||||
.parse_value(in_paren)
|
.parse_value(in_paren)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::eval_order_dependence)]
|
||||||
fn parse_module_item(
|
fn parse_module_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
module: &str,
|
module: &str,
|
||||||
@ -224,7 +225,10 @@ impl<'a> Parser<'a> {
|
|||||||
let value = self
|
let value = self
|
||||||
.modules
|
.modules
|
||||||
.get(module)
|
.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)?;
|
.get_var(var)?;
|
||||||
HigherIntermediateValue::Literal(value.clone())
|
HigherIntermediateValue::Literal(value.clone())
|
||||||
} else {
|
} else {
|
||||||
@ -235,7 +239,10 @@ impl<'a> Parser<'a> {
|
|||||||
let function = self
|
let function = self
|
||||||
.modules
|
.modules
|
||||||
.get(module)
|
.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)
|
.get_fn(fn_name.node)
|
||||||
.ok_or(("Undefined function.", fn_name.span))?;
|
.ok_or(("Undefined function.", fn_name.span))?;
|
||||||
|
|
||||||
@ -251,10 +258,6 @@ impl<'a> Parser<'a> {
|
|||||||
.span(module_span))
|
.span(module_span))
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn parse_module_fn_call(&mut self, name: &str) -> SassResult<Spanned<IntermediateValue>> {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
fn parse_ident_value(&mut self) -> SassResult<Spanned<IntermediateValue>> {
|
fn parse_ident_value(&mut self) -> SassResult<Spanned<IntermediateValue>> {
|
||||||
let Spanned { node: mut s, span } = self.parse_identifier()?;
|
let Spanned { node: mut s, span } = self.parse_identifier()?;
|
||||||
|
|
||||||
|
18
tests/use.rs
18
tests/use.rs
@ -12,33 +12,27 @@ error!(
|
|||||||
);
|
);
|
||||||
error!(
|
error!(
|
||||||
interpolation_in_as_identifier,
|
interpolation_in_as_identifier,
|
||||||
"@use \"sass:math\" as m#{a}th;",
|
"@use \"sass:math\" as m#{a}th;", "Error: expected \";\"."
|
||||||
"Error: expected \";\"."
|
|
||||||
);
|
);
|
||||||
error!(
|
error!(
|
||||||
use_as_quoted_string,
|
use_as_quoted_string,
|
||||||
"@use \"sass:math\" as \"math\";",
|
"@use \"sass:math\" as \"math\";", "Error: Expected identifier."
|
||||||
"Error: Expected identifier."
|
|
||||||
);
|
);
|
||||||
error!(
|
error!(
|
||||||
use_as_missing_s,
|
use_as_missing_s,
|
||||||
"@use \"sass:math\" a math;",
|
"@use \"sass:math\" a math;", "Error: expected \";\"."
|
||||||
"Error: expected \";\"."
|
|
||||||
);
|
);
|
||||||
error!(
|
error!(
|
||||||
unknown_module_get_variable,
|
unknown_module_get_variable,
|
||||||
"a { color: foo.$bar; }",
|
"a { color: foo.$bar; }", "Error: There is no module with the namespace \"foo\"."
|
||||||
"Error: There is no module with the namespace \"foo\"."
|
|
||||||
);
|
);
|
||||||
error!(
|
error!(
|
||||||
unknown_module_get_function,
|
unknown_module_get_function,
|
||||||
"a { color: foo.bar(); }",
|
"a { color: foo.bar(); }", "Error: There is no module with the namespace \"foo\"."
|
||||||
"Error: There is no module with the namespace \"foo\"."
|
|
||||||
);
|
);
|
||||||
error!(
|
error!(
|
||||||
unknown_function,
|
unknown_function,
|
||||||
"@use \"sass:math\";\na { color: math.bar(); }",
|
"@use \"sass:math\";\na { color: math.bar(); }", "Error: Undefined function."
|
||||||
"Error: Undefined function."
|
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
use_as,
|
use_as,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user