From 70cc7afdaf4a262a1a63f2607c606445efbddde9 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Mon, 6 Jul 2020 21:26:57 -0400 Subject: [PATCH] use inspect for builtin function error messages --- src/builtin/color/hsl.rs | 38 +++++++++----------- src/builtin/color/opacity.rs | 32 ++++++----------- src/builtin/color/other.rs | 32 ++++++----------- src/builtin/color/rgb.rs | 28 +++++++-------- src/builtin/list.rs | 14 +++----- src/builtin/map.rs | 14 ++++---- src/builtin/math.rs | 39 +++++---------------- src/builtin/meta.rs | 27 +++++--------- src/builtin/string.rs | 68 +++++++++--------------------------- 9 files changed, 95 insertions(+), 197 deletions(-) diff --git a/src/builtin/color/hsl.rs b/src/builtin/color/hsl.rs index 08d7a06..ac31b7b 100644 --- a/src/builtin/color/hsl.rs +++ b/src/builtin/color/hsl.rs @@ -38,10 +38,7 @@ fn inner_hsl(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> Some(Value::Dimension(n, _)) => n / Number::from(100), Some(v) => { return Err(( - format!( - "$lightness: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$lightness: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -53,10 +50,7 @@ fn inner_hsl(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> Some(Value::Dimension(n, _)) => n / Number::from(100), Some(v) => { return Err(( - format!( - "$saturation: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$saturation: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -68,7 +62,7 @@ fn inner_hsl(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> Some(Value::Dimension(n, _)) => n, Some(v) => { return Err(( - format!("$hue: {} is not a number.", v.to_css_string(args.span())?), + format!("$hue: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -108,7 +102,7 @@ fn inner_hsl(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$hue: {} is not a number.", v.to_css_string(args.span())?), + format!("$hue: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -212,7 +206,7 @@ fn inner_hsl(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$alpha: {} is not a number.", v.to_css_string(args.span())?), + format!("$alpha: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -237,7 +231,7 @@ fn hue(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "color")? { Value::Color(c) => Ok(Value::Dimension(c.hue(), Unit::Deg)), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -249,7 +243,7 @@ fn saturation(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult match parser.arg(&mut args, 0, "color")? { Value::Color(c) => Ok(Value::Dimension(c.saturation(), Unit::Percent)), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -261,7 +255,7 @@ fn lightness(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "color")? { Value::Color(c) => Ok(Value::Dimension(c.lightness(), Unit::Percent)), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -274,7 +268,7 @@ fn adjust_hue(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -302,7 +296,7 @@ fn lighten(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -330,7 +324,7 @@ fn darken(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -389,7 +383,7 @@ fn saturate(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { } v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -404,7 +398,7 @@ fn desaturate(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -438,7 +432,7 @@ fn grayscale(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { } v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -453,7 +447,7 @@ fn complement(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -493,7 +487,7 @@ fn invert(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { ) .into()), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), diff --git a/src/builtin/color/opacity.rs b/src/builtin/color/opacity.rs index 45923d7..648a5e7 100644 --- a/src/builtin/color/opacity.rs +++ b/src/builtin/color/opacity.rs @@ -10,7 +10,7 @@ fn alpha(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "color")? { Value::Color(c) => Ok(Value::Dimension(c.alpha(), Unit::None)), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -26,7 +26,7 @@ fn opacity(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { QuoteKind::None, )), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -39,7 +39,7 @@ fn opacify(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -49,10 +49,7 @@ fn opacify(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Dimension(n, u) => bound!(args, "amount", n, u, 0, 1), v => { return Err(( - format!( - "$amount: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$amount: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -67,7 +64,7 @@ fn fade_in(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -77,10 +74,7 @@ fn fade_in(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Dimension(n, u) => bound!(args, "amount", n, u, 0, 1), v => { return Err(( - format!( - "$amount: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$amount: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -95,7 +89,7 @@ fn transparentize(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -105,10 +99,7 @@ fn transparentize(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult bound!(args, "amount", n, u, 0, 1), v => { return Err(( - format!( - "$amount: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$amount: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -123,7 +114,7 @@ fn fade_out(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -133,10 +124,7 @@ fn fade_out(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Dimension(n, u) => bound!(args, "amount", n, u, 0, 1), v => { return Err(( - format!( - "$amount: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$amount: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) diff --git a/src/builtin/color/other.rs b/src/builtin/color/other.rs index 115c50d..3d87e7d 100644 --- a/src/builtin/color/other.rs +++ b/src/builtin/color/other.rs @@ -19,11 +19,7 @@ macro_rules! opt_rgba { Value::Null => None, v => { return Err(( - format!( - "${}: {} is not a number.", - $arg, - v.to_css_string($args.span())? - ), + format!("${}: {} is not a number.", $arg, v.inspect($args.span())?), $args.span(), ) .into()) @@ -41,11 +37,7 @@ macro_rules! opt_hsl { Value::Null => None, v => { return Err(( - format!( - "${}: {} is not a number.", - $arg, - v.to_css_string($args.span())? - ), + format!("${}: {} is not a number.", $arg, v.inspect($args.span())?), $args.span(), ) .into()) @@ -67,7 +59,7 @@ fn change_color(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -93,7 +85,7 @@ fn change_color(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult None, v => { return Err(( - format!("$hue: {} is not a number.", v.to_css_string(args.span())?), + format!("$hue: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -126,7 +118,7 @@ fn adjust_color(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -152,7 +144,7 @@ fn adjust_color(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult None, v => { return Err(( - format!("$hue: {} is not a number.", v.to_css_string(args.span())?), + format!("$hue: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -196,7 +188,7 @@ fn scale_color(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(span)?), + format!("$color: {} is not a color.", v.inspect(span)?), span, ) .into()) @@ -214,7 +206,7 @@ fn scale_color(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult format!( "${}: Expected {} to have unit \"%\".", $arg, - v.to_css_string($args.span())? + v.inspect($args.span())? ), $args.span(), ) @@ -223,11 +215,7 @@ fn scale_color(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Null => None, v => { return Err(( - format!( - "${}: {} is not a number.", - $arg, - v.to_css_string($args.span())? - ), + format!("${}: {} is not a number.", $arg, v.inspect($args.span())?), $args.span(), ) .into()) @@ -306,7 +294,7 @@ fn ie_hex_str(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Color(c) => c, v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) diff --git a/src/builtin/color/rgb.rs b/src/builtin/color/rgb.rs index 2d3099c..3513eea 100644 --- a/src/builtin/color/rgb.rs +++ b/src/builtin/color/rgb.rs @@ -56,7 +56,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } Some(v) => { return Err(( - format!("$blue: {} is not a number.", v.to_css_string(args.span())?), + format!("$blue: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -82,7 +82,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } Some(v) => { return Err(( - format!("$green: {} is not a number.", v.to_css_string(args.span())?), + format!("$green: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -107,7 +107,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } Some(v) => { return Err(( - format!("$red: {} is not a number.", v.to_css_string(args.span())?), + format!("$red: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -135,7 +135,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -169,7 +169,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$alpha: {} is not a number.", v.to_css_string(args.span())?), + format!("$alpha: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -213,7 +213,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$red: {} is not a number.", v.to_css_string(args.span())?), + format!("$red: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -254,7 +254,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$green: {} is not a number.", v.to_css_string(args.span())?), + format!("$green: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -294,7 +294,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$blue: {} is not a number.", v.to_css_string(args.span())?), + format!("$blue: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -331,7 +331,7 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser<'_>) -> } v => { return Err(( - format!("$alpha: {} is not a number.", v.to_css_string(args.span())?), + format!("$alpha: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -356,7 +356,7 @@ fn red(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "color")? { Value::Color(c) => Ok(Value::Dimension(c.red(), Unit::None)), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -368,7 +368,7 @@ fn green(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "color")? { Value::Color(c) => Ok(Value::Dimension(c.green(), Unit::None)), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -380,7 +380,7 @@ fn blue(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "color")? { Value::Color(c) => Ok(Value::Dimension(c.blue(), Unit::None)), v => Err(( - format!("$color: {} is not a color.", v.to_css_string(args.span())?), + format!("$color: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()), @@ -393,7 +393,7 @@ fn mix(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Color(c) => c, v => { return Err(( - format!("$color1: {} is not a color.", v.to_css_string(args.span())?), + format!("$color1: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) @@ -404,7 +404,7 @@ fn mix(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Color(c) => c, v => { return Err(( - format!("$color2: {} is not a color.", v.to_css_string(args.span())?), + format!("$color2: {} is not a color.", v.inspect(args.span())?), args.span(), ) .into()) diff --git a/src/builtin/list.rs b/src/builtin/list.rs index 11409af..72ec0f4 100644 --- a/src/builtin/list.rs +++ b/src/builtin/list.rs @@ -26,7 +26,7 @@ fn nth(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Dimension(num, _) => num, v => { return Err(( - format!("$n: {} is not a number.", v.to_css_string(args.span())?), + format!("$n: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -83,7 +83,7 @@ fn set_nth(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Dimension(num, _) => num, v => { return Err(( - format!("$n: {} is not a number.", v.to_css_string(args.span())?), + format!("$n: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -146,10 +146,7 @@ fn append(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { }, v => { return Err(( - format!( - "$separator: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$separator: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -199,10 +196,7 @@ fn join(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { }, v => { return Err(( - format!( - "$separator: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$separator: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) diff --git a/src/builtin/map.rs b/src/builtin/map.rs index 3d240f3..3f43594 100644 --- a/src/builtin/map.rs +++ b/src/builtin/map.rs @@ -16,7 +16,7 @@ fn map_get(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::List(v, ..) if v.is_empty() => SassMap::new(), v => { return Err(( - format!("$map: {} is not a map.", v.to_css_string(args.span())?), + format!("$map: {} is not a map.", v.inspect(args.span())?), args.span(), ) .into()) @@ -33,7 +33,7 @@ fn map_has_key(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::List(v, ..) if v.is_empty() => SassMap::new(), v => { return Err(( - format!("$map: {} is not a map.", v.to_css_string(args.span())?), + format!("$map: {} is not a map.", v.inspect(args.span())?), args.span(), ) .into()) @@ -49,7 +49,7 @@ fn map_keys(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::List(v, ..) if v.is_empty() => SassMap::new(), v => { return Err(( - format!("$map: {} is not a map.", v.to_css_string(args.span())?), + format!("$map: {} is not a map.", v.inspect(args.span())?), args.span(), ) .into()) @@ -69,7 +69,7 @@ fn map_values(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::List(v, ..) if v.is_empty() => SassMap::new(), v => { return Err(( - format!("$map: {} is not a map.", v.to_css_string(args.span())?), + format!("$map: {} is not a map.", v.inspect(args.span())?), args.span(), ) .into()) @@ -89,7 +89,7 @@ fn map_merge(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::List(v, ..) if v.is_empty() => SassMap::new(), v => { return Err(( - format!("$map1: {} is not a map.", v.to_css_string(args.span())?), + format!("$map1: {} is not a map.", v.inspect(args.span())?), args.span(), ) .into()) @@ -100,7 +100,7 @@ fn map_merge(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::List(v, ..) if v.is_empty() => SassMap::new(), v => { return Err(( - format!("$map2: {} is not a map.", v.to_css_string(args.span())?), + format!("$map2: {} is not a map.", v.inspect(args.span())?), args.span(), ) .into()) @@ -116,7 +116,7 @@ fn map_remove(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::List(v, ..) if v.is_empty() => SassMap::new(), v => { return Err(( - format!("$map: {} is not a map.", v.to_css_string(args.span())?), + format!("$map: {} is not a map.", v.inspect(args.span())?), args.span(), ) .into()) diff --git a/src/builtin/math.rs b/src/builtin/math.rs index d7192ce..bbd597f 100644 --- a/src/builtin/math.rs +++ b/src/builtin/math.rs @@ -21,7 +21,7 @@ fn percentage(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult return Err(( format!( "$number: Expected {} to have no units.", - v.to_css_string(args.span())? + v.inspect(args.span())? ), args.span(), ) @@ -29,10 +29,7 @@ fn percentage(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult } v => { return Err(( - format!( - "$number: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -46,10 +43,7 @@ fn round(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "number")? { Value::Dimension(n, u) => Ok(Value::Dimension(n.round(), u)), v => Err(( - format!( - "$number: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()), @@ -61,10 +55,7 @@ fn ceil(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "number")? { Value::Dimension(n, u) => Ok(Value::Dimension(n.ceil(), u)), v => Err(( - format!( - "$number: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()), @@ -76,10 +67,7 @@ fn floor(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "number")? { Value::Dimension(n, u) => Ok(Value::Dimension(n.floor(), u)), v => Err(( - format!( - "$number: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()), @@ -91,10 +79,7 @@ fn abs(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "number")? { Value::Dimension(n, u) => Ok(Value::Dimension(n.abs(), u)), v => Err(( - format!( - "$number: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()), @@ -107,10 +92,7 @@ fn comparable(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Dimension(_, u) => u, v => { return Err(( - format!( - "$number1: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number1: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -120,10 +102,7 @@ fn comparable(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::Dimension(_, u) => u, v => { return Err(( - format!( - "$number2: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number2: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -148,7 +127,7 @@ fn random(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { } v => { return Err(( - format!("$limit: {} is not a number.", v.to_css_string(args.span())?), + format!("$limit: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) diff --git a/src/builtin/meta.rs b/src/builtin/meta.rs index b29e783..a86c633 100644 --- a/src/builtin/meta.rs +++ b/src/builtin/meta.rs @@ -43,10 +43,7 @@ fn feature_exists(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::False, }), v => Err(( - format!( - "$feature: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$feature: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -59,10 +56,7 @@ fn unit(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Dimension(_, u) => u.to_string(), v => { return Err(( - format!( - "$number: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$number: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -108,7 +102,7 @@ fn variable_exists(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Err(( - format!("$name: {} is not a string.", v.to_css_string(args.span())?), + format!("$name: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -122,7 +116,7 @@ fn global_variable_exists(mut args: CallArgs, parser: &mut Parser<'_>) -> SassRe parser.global_scope.var_exists_no_global(&s.into()), )), v => Err(( - format!("$name: {} is not a string.", v.to_css_string(args.span())?), + format!("$name: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -136,7 +130,7 @@ fn mixin_exists(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Err(( - format!("$name: {} is not a string.", v.to_css_string(args.span())?), + format!("$name: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -150,7 +144,7 @@ fn function_exists(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Err(( - format!("$name: {} is not a string.", v.to_css_string(args.span())?), + format!("$name: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -163,7 +157,7 @@ fn get_function(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult s, v => { return Err(( - format!("$name: {} is not a string.", v.to_css_string(args.span())?), + format!("$name: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -177,10 +171,7 @@ fn get_function(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult None, v => { return Err(( - format!( - "$module: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$module: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -219,7 +210,7 @@ fn call(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { return Err(( format!( "$function: {} is not a function reference.", - v.to_css_string(args.span())? + v.inspect(args.span())? ), args.span(), ) diff --git a/src/builtin/string.rs b/src/builtin/string.rs index 521ba54..5357e8a 100644 --- a/src/builtin/string.rs +++ b/src/builtin/string.rs @@ -23,10 +23,7 @@ fn to_upper_case(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -41,10 +38,7 @@ fn to_lower_case(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -59,10 +53,7 @@ fn str_length(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Unit::None, )), v => Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -74,10 +65,7 @@ fn quote(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "string")? { Value::String(i, _) => Ok(Value::String(i, QuoteKind::Quoted)), v => Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -89,10 +77,7 @@ fn unquote(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { match parser.arg(&mut args, 0, "string")? { i @ Value::String(..) => Ok(i.unquote()), v => Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()), @@ -105,10 +90,7 @@ fn str_slice(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::String(s, q) => (s, q), v => { return Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -131,7 +113,7 @@ fn str_slice(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { return Err(( format!( "$start: Expected {} to have no units.", - v.to_css_string(args.span())? + v.inspect(args.span())? ), args.span(), ) @@ -139,10 +121,7 @@ fn str_slice(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { } v => { return Err(( - format!( - "$start-at: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$start-at: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -164,7 +143,7 @@ fn str_slice(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { return Err(( format!( "$end: Expected {} to have no units.", - v.to_css_string(args.span())? + v.inspect(args.span())? ), args.span(), ) @@ -173,10 +152,7 @@ fn str_slice(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::Null => str_len, v => { return Err(( - format!( - "$end-at: {} is not a number.", - v.to_css_string(args.span())? - ), + format!("$end-at: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into()) @@ -207,10 +183,7 @@ fn str_index(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::String(i, _) => i, v => { return Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -221,10 +194,7 @@ fn str_index(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { Value::String(i, _) => i, v => { return Err(( - format!( - "$substring: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$substring: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -243,10 +213,7 @@ fn str_insert(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::String(i, q) => (i, q), v => { return Err(( - format!( - "$string: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$string: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -257,10 +224,7 @@ fn str_insert(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult Value::String(i, _) => i, v => { return Err(( - format!( - "$insert: {} is not a string.", - v.to_css_string(args.span())? - ), + format!("$insert: {} is not a string.", v.inspect(args.span())?), args.span(), ) .into()) @@ -276,7 +240,7 @@ fn str_insert(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult return Err(( format!( "$index: Expected {} to have no units.", - v.to_css_string(args.span())? + v.inspect(args.span())? ), args.span(), ) @@ -284,7 +248,7 @@ fn str_insert(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult } v => { return Err(( - format!("$index: {} is not a number.", v.to_css_string(args.span())?), + format!("$index: {} is not a number.", v.inspect(args.span())?), args.span(), ) .into())