clippy
This commit is contained in:
parent
21d830d6ff
commit
ec83a9dff7
@ -121,7 +121,7 @@ impl Function {
|
|||||||
self.args(args, scope, super_selector)?;
|
self.args(args, scope, super_selector)?;
|
||||||
let stmts = self.eval_body(super_selector)?;
|
let stmts = self.eval_body(super_selector)?;
|
||||||
self.call(super_selector, stmts)?
|
self.call(super_selector, stmts)?
|
||||||
.ok_or(("Function finished without @return.", self.pos).into())
|
.ok_or_else(|| ("Function finished without @return.", self.pos).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn call(
|
pub fn call(
|
||||||
|
@ -80,10 +80,10 @@ fn change_color(mut args: CallArgs, scope: &Scope, super_selector: &Selector) ->
|
|||||||
|
|
||||||
if red.is_some() || green.is_some() || blue.is_some() {
|
if red.is_some() || green.is_some() || blue.is_some() {
|
||||||
return Ok(Value::Color(Box::new(Color::from_rgba(
|
return Ok(Value::Color(Box::new(Color::from_rgba(
|
||||||
red.unwrap_or(color.red()),
|
red.unwrap_or_else(|| color.red()),
|
||||||
green.unwrap_or(color.green()),
|
green.unwrap_or_else(|| color.green()),
|
||||||
blue.unwrap_or(color.blue()),
|
blue.unwrap_or_else(|| color.blue()),
|
||||||
alpha.unwrap_or(color.alpha()),
|
alpha.unwrap_or_else(|| color.alpha()),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,10 +147,10 @@ fn adjust_color(mut args: CallArgs, scope: &Scope, super_selector: &Selector) ->
|
|||||||
|
|
||||||
if red.is_some() || green.is_some() || blue.is_some() {
|
if red.is_some() || green.is_some() || blue.is_some() {
|
||||||
return Ok(Value::Color(Box::new(Color::from_rgba(
|
return Ok(Value::Color(Box::new(Color::from_rgba(
|
||||||
color.red() + red.unwrap_or(Number::zero()),
|
color.red() + red.unwrap_or_else(Number::zero),
|
||||||
color.green() + green.unwrap_or(Number::zero()),
|
color.green() + green.unwrap_or_else(Number::zero),
|
||||||
color.blue() + blue.unwrap_or(Number::zero()),
|
color.blue() + blue.unwrap_or_else(Number::zero),
|
||||||
color.alpha() + alpha.unwrap_or(Number::zero()),
|
color.alpha() + alpha.unwrap_or_else(Number::zero),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,10 +189,10 @@ fn adjust_color(mut args: CallArgs, scope: &Scope, super_selector: &Selector) ->
|
|||||||
// Color::as_hsla() returns more exact values than Color::hue(), etc.
|
// Color::as_hsla() returns more exact values than Color::hue(), etc.
|
||||||
let (this_hue, this_saturation, this_luminance, this_alpha) = color.as_hsla();
|
let (this_hue, this_saturation, this_luminance, this_alpha) = color.as_hsla();
|
||||||
return Ok(Value::Color(Box::new(Color::from_hsla(
|
return Ok(Value::Color(Box::new(Color::from_hsla(
|
||||||
this_hue + hue.unwrap_or(Number::zero()),
|
this_hue + hue.unwrap_or_else(Number::zero),
|
||||||
this_saturation + saturation.unwrap_or(Number::zero()),
|
this_saturation + saturation.unwrap_or_else(Number::zero),
|
||||||
this_luminance + luminance.unwrap_or(Number::zero()),
|
this_luminance + luminance.unwrap_or_else(Number::zero),
|
||||||
this_alpha + alpha.unwrap_or(Number::zero()),
|
this_alpha + alpha.unwrap_or_else(Number::zero),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,22 +266,22 @@ fn scale_color(mut args: CallArgs, scope: &Scope, super_selector: &Selector) ->
|
|||||||
return Ok(Value::Color(Box::new(Color::from_rgba(
|
return Ok(Value::Color(Box::new(Color::from_rgba(
|
||||||
scale(
|
scale(
|
||||||
color.red(),
|
color.red(),
|
||||||
red.unwrap_or(Number::zero()),
|
red.unwrap_or_else(Number::zero),
|
||||||
Number::from(255),
|
Number::from(255),
|
||||||
),
|
),
|
||||||
scale(
|
scale(
|
||||||
color.green(),
|
color.green(),
|
||||||
green.unwrap_or(Number::zero()),
|
green.unwrap_or_else(Number::zero),
|
||||||
Number::from(255),
|
Number::from(255),
|
||||||
),
|
),
|
||||||
scale(
|
scale(
|
||||||
color.blue(),
|
color.blue(),
|
||||||
blue.unwrap_or(Number::zero()),
|
blue.unwrap_or_else(Number::zero),
|
||||||
Number::from(255),
|
Number::from(255),
|
||||||
),
|
),
|
||||||
scale(
|
scale(
|
||||||
color.alpha(),
|
color.alpha(),
|
||||||
alpha.unwrap_or(Number::zero()),
|
alpha.unwrap_or_else(Number::zero),
|
||||||
Number::one(),
|
Number::one(),
|
||||||
),
|
),
|
||||||
))));
|
))));
|
||||||
@ -313,15 +313,19 @@ fn scale_color(mut args: CallArgs, scope: &Scope, super_selector: &Selector) ->
|
|||||||
scale(this_hue, Number::zero(), Number::from(360)),
|
scale(this_hue, Number::zero(), Number::from(360)),
|
||||||
scale(
|
scale(
|
||||||
this_saturation,
|
this_saturation,
|
||||||
saturation.unwrap_or(Number::zero()),
|
saturation.unwrap_or_else(Number::zero),
|
||||||
Number::one(),
|
Number::one(),
|
||||||
),
|
),
|
||||||
scale(
|
scale(
|
||||||
this_luminance,
|
this_luminance,
|
||||||
luminance.unwrap_or(Number::zero()),
|
luminance.unwrap_or_else(Number::zero),
|
||||||
|
Number::one(),
|
||||||
|
),
|
||||||
|
scale(
|
||||||
|
this_alpha,
|
||||||
|
alpha.unwrap_or_else(Number::zero),
|
||||||
Number::one(),
|
Number::one(),
|
||||||
),
|
),
|
||||||
scale(this_alpha, alpha.unwrap_or(Number::zero()), Number::one()),
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ fn feature_exists(
|
|||||||
) -> SassResult<Value> {
|
) -> SassResult<Value> {
|
||||||
args.max_args(1)?;
|
args.max_args(1)?;
|
||||||
match arg!(args, scope, super_selector, 0, "feature") {
|
match arg!(args, scope, super_selector, 0, "feature") {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
Value::String(s, _) => Ok(match s.as_str() {
|
Value::String(s, _) => Ok(match s.as_str() {
|
||||||
// A local variable will shadow a global variable unless
|
// A local variable will shadow a global variable unless
|
||||||
// `!global` is used.
|
// `!global` is used.
|
||||||
@ -85,11 +86,11 @@ fn type_of(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> Sass
|
|||||||
|
|
||||||
fn unitless(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> SassResult<Value> {
|
fn unitless(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> SassResult<Value> {
|
||||||
args.max_args(1)?;
|
args.max_args(1)?;
|
||||||
match arg!(args, scope, super_selector, 0, "number") {
|
Ok(match arg!(args, scope, super_selector, 0, "number") {
|
||||||
Value::Dimension(_, Unit::None) => Ok(Value::True),
|
Value::Dimension(_, Unit::None) => Value::True,
|
||||||
Value::Dimension(_, _) => Ok(Value::False),
|
Value::Dimension(_, _) => Value::False,
|
||||||
_ => Ok(Value::True),
|
_ => Value::True,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inspect(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> SassResult<Value> {
|
fn inspect(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> SassResult<Value> {
|
||||||
|
27
src/lib.rs
27
src/lib.rs
@ -40,11 +40,10 @@ grass input.scss
|
|||||||
clippy::implicit_return,
|
clippy::implicit_return,
|
||||||
// Self { .. } is less explicit than Foo { .. }
|
// Self { .. } is less explicit than Foo { .. }
|
||||||
clippy::use_self,
|
clippy::use_self,
|
||||||
// this is way too pedantic -- some things don't need docs!
|
// this is too pedantic -- some things don't need docs!
|
||||||
clippy::missing_docs_in_private_items,
|
clippy::missing_docs_in_private_items,
|
||||||
// unreachable!() has many valid use cases
|
|
||||||
clippy::unreachable,
|
clippy::unreachable,
|
||||||
// _ => {} has many valid use cases
|
// this disallows binding as well
|
||||||
clippy::wildcard_enum_match_arm,
|
clippy::wildcard_enum_match_arm,
|
||||||
// this is too pedantic -- we are allowed to add numbers!
|
// this is too pedantic -- we are allowed to add numbers!
|
||||||
clippy::integer_arithmetic,
|
clippy::integer_arithmetic,
|
||||||
@ -53,12 +52,15 @@ grass input.scss
|
|||||||
clippy::missing_errors_doc,
|
clippy::missing_errors_doc,
|
||||||
// this incorrectly results in errors for types that derive `Debug`
|
// this incorrectly results in errors for types that derive `Debug`
|
||||||
// https://github.com/rust-lang/rust-clippy/issues/4980
|
// https://github.com/rust-lang/rust-clippy/issues/4980
|
||||||
clippy::let_underscore_must_use,
|
// clippy::let_underscore_must_use,
|
||||||
// this is too pedantic -- it results in some names being less explicit
|
// this is too pedantic -- it results in some names being less explicit
|
||||||
// than they should
|
// than they should
|
||||||
clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
// this is too pedantic -- it is sometimes useful to break up `impl`s
|
// this is too pedantic -- it is sometimes useful to break up `impl`s
|
||||||
clippy::multiple_inherent_impl,
|
clippy::multiple_inherent_impl,
|
||||||
|
// filter isn't fallible
|
||||||
|
clippy::filter_map,
|
||||||
|
clippy::else_if_without_else,
|
||||||
|
|
||||||
// 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
|
||||||
@ -72,8 +74,8 @@ grass input.scss
|
|||||||
clippy::cast_possible_truncation,
|
clippy::cast_possible_truncation,
|
||||||
clippy::single_match_else,
|
clippy::single_match_else,
|
||||||
clippy::indexing_slicing,
|
clippy::indexing_slicing,
|
||||||
clippy::match_same_arms,
|
// clippy::match_same_arms,
|
||||||
clippy::or_fun_call,
|
// clippy::or_fun_call,
|
||||||
clippy::redundant_pub_crate,
|
clippy::redundant_pub_crate,
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(feature = "nightly", feature(track_caller))]
|
#![cfg_attr(feature = "nightly", feature(track_caller))]
|
||||||
@ -350,18 +352,7 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
|
|||||||
AtRule::Mixin(name, mixin) => Expr::MixinDecl(name, mixin),
|
AtRule::Mixin(name, mixin) => Expr::MixinDecl(name, mixin),
|
||||||
AtRule::Function(name, func) => Expr::FunctionDecl(name, func),
|
AtRule::Function(name, func) => Expr::FunctionDecl(name, func),
|
||||||
AtRule::Charset => todo!("@charset as expr"),
|
AtRule::Charset => todo!("@charset as expr"),
|
||||||
d @ AtRule::Debug(..) => Expr::AtRule(d),
|
a => Expr::AtRule(a),
|
||||||
w @ AtRule::Warn(..) => Expr::AtRule(w),
|
|
||||||
a @ AtRule::Return(_) => Expr::AtRule(a),
|
|
||||||
c @ AtRule::Content => Expr::AtRule(c),
|
|
||||||
f @ AtRule::If(..) => Expr::AtRule(f),
|
|
||||||
f @ AtRule::For(..) => Expr::AtRule(f),
|
|
||||||
f @ AtRule::While(..) => Expr::AtRule(f),
|
|
||||||
f @ AtRule::Each(..) => Expr::AtRule(f),
|
|
||||||
u @ AtRule::Unknown(..) => Expr::AtRule(u),
|
|
||||||
u @ AtRule::AtRoot(..) => Expr::AtRule(u),
|
|
||||||
u @ AtRule::Include(..) => Expr::AtRule(u),
|
|
||||||
u @ AtRule::Media(..) => Expr::AtRule(u),
|
|
||||||
},
|
},
|
||||||
span,
|
span,
|
||||||
}));
|
}));
|
||||||
|
@ -90,7 +90,7 @@ impl Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_var<T: Into<Identifier>>(&self, name: Spanned<T>) -> SassResult<Spanned<Value>> {
|
pub fn get_var<T: Into<Identifier>>(&self, name: Spanned<T>) -> SassResult<Spanned<Value>> {
|
||||||
let name = name.map_node(|n| n.into());
|
let name = name.map_node(Into::into);
|
||||||
match self.vars.get(&name.node) {
|
match self.vars.get(&name.node) {
|
||||||
Some(v) => Ok(v.clone()),
|
Some(v) => Ok(v.clone()),
|
||||||
None => get_global_var(name),
|
None => get_global_var(name),
|
||||||
@ -112,7 +112,7 @@ impl Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mixin<T: Into<Identifier>>(&self, name: Spanned<T>) -> SassResult<Mixin> {
|
pub fn get_mixin<T: Into<Identifier>>(&self, name: Spanned<T>) -> SassResult<Mixin> {
|
||||||
let name = name.map_node(|n| n.into());
|
let name = name.map_node(Into::into);
|
||||||
match self.mixins.get(&name.node) {
|
match self.mixins.get(&name.node) {
|
||||||
Some(v) => Ok(v.clone()),
|
Some(v) => Ok(v.clone()),
|
||||||
None => get_global_mixin(name),
|
None => get_global_mixin(name),
|
||||||
@ -129,7 +129,7 @@ impl Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_fn<T: Into<Identifier>>(&self, name: Spanned<T>) -> SassResult<Function> {
|
pub fn get_fn<T: Into<Identifier>>(&self, name: Spanned<T>) -> SassResult<Function> {
|
||||||
let name = name.map_node(|n| n.into());
|
let name = name.map_node(Into::into);
|
||||||
match self.functions.get(&name.node) {
|
match self.functions.get(&name.node) {
|
||||||
Some(v) => Ok(v.clone()),
|
Some(v) => Ok(v.clone()),
|
||||||
None => get_global_fn(name),
|
None => get_global_fn(name),
|
||||||
|
@ -419,28 +419,29 @@ impl Selector {
|
|||||||
} else {
|
} else {
|
||||||
todo!()
|
todo!()
|
||||||
};
|
};
|
||||||
if is_selector_name_char(t.kind) {
|
|
||||||
let name = eat_ident_no_interpolation(toks, false, t.pos)?.node;
|
if !is_selector_name_char(t.kind) {
|
||||||
Ok(
|
|
||||||
if toks.peek().is_some() && toks.peek().unwrap().kind == '(' {
|
|
||||||
toks.next();
|
|
||||||
let mut inner_toks = read_until_closing_paren(toks)?;
|
|
||||||
inner_toks.pop();
|
|
||||||
let inner = Selector::from_tokens(
|
|
||||||
&mut inner_toks.into_iter().peekmore(),
|
|
||||||
scope,
|
|
||||||
super_selector,
|
|
||||||
)?;
|
|
||||||
SelectorKind::PseudoParen(name, inner)
|
|
||||||
} else if is_pseudo_element {
|
|
||||||
SelectorKind::PseudoElement(name)
|
|
||||||
} else {
|
|
||||||
SelectorKind::Pseudo(name)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return Err(("Expected identifier.", t.pos).into());
|
return Err(("Expected identifier.", t.pos).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let name = eat_ident_no_interpolation(toks, false, t.pos)?.node;
|
||||||
|
Ok(
|
||||||
|
if toks.peek().is_some() && toks.peek().unwrap().kind == '(' {
|
||||||
|
toks.next();
|
||||||
|
let mut inner_toks = read_until_closing_paren(toks)?;
|
||||||
|
inner_toks.pop();
|
||||||
|
let inner = Selector::from_tokens(
|
||||||
|
&mut inner_toks.into_iter().peekmore(),
|
||||||
|
scope,
|
||||||
|
super_selector,
|
||||||
|
)?;
|
||||||
|
SelectorKind::PseudoParen(name, inner)
|
||||||
|
} else if is_pseudo_element {
|
||||||
|
SelectorKind::PseudoElement(name)
|
||||||
|
} else {
|
||||||
|
SelectorKind::Pseudo(name)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn replace(super_selector: &Selector, this: Selector) -> Selector {
|
pub fn replace(super_selector: &Selector, this: Selector) -> Selector {
|
||||||
|
@ -165,7 +165,6 @@ impl<'a> StyleParser<'a> {
|
|||||||
let value = self.parse_style_value(toks, scope, tok.pos)?;
|
let value = self.parse_style_value(toks, scope, tok.pos)?;
|
||||||
let t = toks.peek().ok_or(("expected more input.", value.span))?;
|
let t = toks.peek().ok_or(("expected more input.", value.span))?;
|
||||||
match t.kind {
|
match t.kind {
|
||||||
'}' => {}
|
|
||||||
';' => {
|
';' => {
|
||||||
toks.next();
|
toks.next();
|
||||||
devour_whitespace(toks);
|
devour_whitespace(toks);
|
||||||
|
@ -182,6 +182,9 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
| '?'
|
| '?'
|
||||||
| '~'
|
| '~'
|
||||||
| '|'
|
| '|'
|
||||||
|
| '`'
|
||||||
|
| '\''
|
||||||
|
| '"'
|
||||||
| '\u{7f}'..=std::char::MAX => {
|
| '\u{7f}'..=std::char::MAX => {
|
||||||
rules.extend(self.eat_rules(&Selector::new(), &mut Scope::new())?)
|
rules.extend(self.eat_rules(&Selector::new(), &mut Scope::new())?)
|
||||||
}
|
}
|
||||||
@ -336,8 +339,9 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
AtRule::AtRoot(root_rules) => rules.extend(root_rules),
|
AtRule::AtRoot(root_rules) => rules.extend(root_rules),
|
||||||
AtRule::Unknown(..) => rules.push(rule.map_node(Stmt::AtRule)),
|
AtRule::Unknown(..) | AtRule::Media(..) => {
|
||||||
AtRule::Media(..) => rules.push(rule.map_node(Stmt::AtRule)),
|
rules.push(rule.map_node(Stmt::AtRule))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,9 +359,6 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
'{' | '!' => {
|
'{' | '!' => {
|
||||||
return Err(("expected \"}\".", self.lexer.next().unwrap().pos).into());
|
return Err(("expected \"}\".", self.lexer.next().unwrap().pos).into());
|
||||||
}
|
}
|
||||||
'`' | '\'' | '"' => {
|
|
||||||
return Err(("expected selector.", self.lexer.next().unwrap().pos).into());
|
|
||||||
}
|
|
||||||
'}' => return Err(("unmatched \"}\".", self.lexer.next().unwrap().pos).into()),
|
'}' => return Err(("unmatched \"}\".", self.lexer.next().unwrap().pos).into()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -400,11 +401,7 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
AtRule::Warn(ref message) => self.warn(expr.span, message),
|
AtRule::Warn(ref message) => self.warn(expr.span, message),
|
||||||
AtRule::Mixin(..) | AtRule::Function(..) => todo!(),
|
AtRule::Mixin(..) | AtRule::Function(..) => todo!(),
|
||||||
AtRule::Charset => todo!(),
|
AtRule::Charset => todo!(),
|
||||||
r @ AtRule::Unknown(..) => stmts.push(Spanned {
|
r @ AtRule::Unknown(..) | r @ AtRule::Media(..) => stmts.push(Spanned {
|
||||||
node: Stmt::AtRule(r),
|
|
||||||
span,
|
|
||||||
}),
|
|
||||||
r @ AtRule::Media(..) => stmts.push(Spanned {
|
|
||||||
node: Stmt::AtRule(r),
|
node: Stmt::AtRule(r),
|
||||||
span,
|
span,
|
||||||
}),
|
}),
|
||||||
|
@ -83,6 +83,7 @@ pub(crate) fn eat_number<I: Iterator<Item = Token>>(
|
|||||||
|
|
||||||
let mut times_ten = String::new();
|
let mut times_ten = String::new();
|
||||||
let mut times_ten_is_postive = true;
|
let mut times_ten_is_postive = true;
|
||||||
|
#[allow(clippy::never_loop)]
|
||||||
loop {
|
loop {
|
||||||
// TODO: https://github.com/rust-lang/rust/issues/54883
|
// TODO: https://github.com/rust-lang/rust/issues/54883
|
||||||
if let Some(Token { kind: 'e', .. }) | Some(Token { kind: 'E', .. }) = toks.peek() {
|
if let Some(Token { kind: 'e', .. }) | Some(Token { kind: 'E', .. }) = toks.peek() {
|
||||||
|
@ -135,14 +135,7 @@ impl Value {
|
|||||||
}
|
}
|
||||||
_ => Cow::Owned(format!("{}{}", num, unit)),
|
_ => Cow::Owned(format!("{}{}", num, unit)),
|
||||||
},
|
},
|
||||||
Self::Map(..) => {
|
Self::Map(..) | Self::Function(..) => {
|
||||||
return Err((
|
|
||||||
format!("{} isn't a valid CSS value.", self.inspect(span)?),
|
|
||||||
span,
|
|
||||||
)
|
|
||||||
.into())
|
|
||||||
}
|
|
||||||
Self::Function(..) => {
|
|
||||||
return Err((
|
return Err((
|
||||||
format!("{} isn't a valid CSS value.", self.inspect(span)?),
|
format!("{} isn't a valid CSS value.", self.inspect(span)?),
|
||||||
span,
|
span,
|
||||||
|
@ -76,7 +76,7 @@ impl Add<i32> for Integer {
|
|||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: i32) -> Self::Output {
|
fn add(self, rhs: i32) -> Self::Output {
|
||||||
match self {
|
match self {
|
||||||
Self::Machine(v) => match v.checked_add(rhs as i64) {
|
Self::Machine(v) => match v.checked_add(i64::from(rhs)) {
|
||||||
Some(v) => Self::Machine(v),
|
Some(v) => Self::Machine(v),
|
||||||
None => Self::Big(BigInt::from(v) + rhs),
|
None => Self::Big(BigInt::from(v) + rhs),
|
||||||
},
|
},
|
||||||
|
@ -125,10 +125,9 @@ impl Value {
|
|||||||
Op::Mul => lhs.mul(*rhs, span)?,
|
Op::Mul => lhs.mul(*rhs, span)?,
|
||||||
Op::Div => lhs.div(*rhs, span)?,
|
Op::Div => lhs.div(*rhs, span)?,
|
||||||
Op::Rem => lhs.rem(*rhs, span)?,
|
Op::Rem => lhs.rem(*rhs, span)?,
|
||||||
Op::GreaterThan => return lhs.cmp(*rhs, op, span),
|
Op::GreaterThan | Op::GreaterThanEqual | Op::LessThan | Op::LessThanEqual => {
|
||||||
Op::GreaterThanEqual => return lhs.cmp(*rhs, op, span),
|
return lhs.cmp(*rhs, op, span)
|
||||||
Op::LessThan => return lhs.cmp(*rhs, op, span),
|
}
|
||||||
Op::LessThanEqual => return lhs.cmp(*rhs, op, span),
|
|
||||||
Op::Not => unreachable!(),
|
Op::Not => unreachable!(),
|
||||||
Op::And => {
|
Op::And => {
|
||||||
if lhs.is_true(span)? {
|
if lhs.is_true(span)? {
|
||||||
|
@ -163,7 +163,7 @@ enum IntermediateValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IntermediateValue {
|
impl IntermediateValue {
|
||||||
fn span(self, span: Span) -> Spanned<Self> {
|
const fn span(self, span: Span) -> Spanned<Self> {
|
||||||
Spanned { node: self, span }
|
Spanned { node: self, span }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -655,7 +655,7 @@ impl Value {
|
|||||||
.span(span));
|
.span(span));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(c) = NAMED_COLORS.get_by_name(&lower.as_str()) {
|
if let Some(c) = NAMED_COLORS.get_by_name(lower.as_str()) {
|
||||||
return Ok(IntermediateValue::Value(Value::Color(Box::new(Color::new(
|
return Ok(IntermediateValue::Value(Value::Color(Box::new(Color::new(
|
||||||
c[0], c[1], c[2], c[3], s,
|
c[0], c[1], c[2], c[3], s,
|
||||||
))))
|
))))
|
||||||
@ -791,7 +791,7 @@ impl Value {
|
|||||||
let mut span = toks.next().unwrap().pos();
|
let mut span = toks.next().unwrap().pos();
|
||||||
let mut inner = match read_until_closing_paren(toks) {
|
let mut inner = match read_until_closing_paren(toks) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => return Some(Err(e.into())),
|
Err(e) => return Some(Err(e)),
|
||||||
};
|
};
|
||||||
// todo: the above shouldn't eat the closing paren
|
// todo: the above shouldn't eat the closing paren
|
||||||
if let Some(last_tok) = inner.pop() {
|
if let Some(last_tok) = inner.pop() {
|
||||||
@ -833,7 +833,7 @@ impl Value {
|
|||||||
let mut span = toks.next().unwrap().pos();
|
let mut span = toks.next().unwrap().pos();
|
||||||
let mut inner = match read_until_closing_square_brace(toks) {
|
let mut inner = match read_until_closing_square_brace(toks) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => return Some(Err(e.into())),
|
Err(e) => return Some(Err(e)),
|
||||||
};
|
};
|
||||||
if let Some(last_tok) = inner.pop() {
|
if let Some(last_tok) = inner.pop() {
|
||||||
if last_tok.kind != ']' {
|
if last_tok.kind != ']' {
|
||||||
|
@ -38,8 +38,7 @@ impl SassFunction {
|
|||||||
/// Used mainly in debugging and `inspect()`
|
/// Used mainly in debugging and `inspect()`
|
||||||
pub fn name(&self) -> &Identifier {
|
pub fn name(&self) -> &Identifier {
|
||||||
match self {
|
match self {
|
||||||
Self::Builtin(_, name) => name,
|
Self::Builtin(_, name) | Self::UserDefined(_, name) => name,
|
||||||
Self::UserDefined(_, name) => name,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user