rustfmt
This commit is contained in:
parent
1d80b00c20
commit
46a6fd90f6
@ -682,4 +682,4 @@ impl Display for Pos {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "line:{} col:{}", self.line, self.column)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
src/error.rs
17
src/error.rs
@ -6,16 +6,22 @@ use std::io;
|
||||
#[derive(Debug)]
|
||||
pub struct SassError {
|
||||
message: String,
|
||||
pos: Pos
|
||||
pos: Pos,
|
||||
}
|
||||
|
||||
impl SassError {
|
||||
pub fn new<S: Into<String>>(message: S, pos: Pos) -> Self {
|
||||
SassError { message: message.into(), pos }
|
||||
SassError {
|
||||
message: message.into(),
|
||||
pos,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unexpected_eof(pos: Pos) -> Self {
|
||||
SassError { message: String::from("unexpected eof"), pos }
|
||||
SassError {
|
||||
message: String::from("unexpected eof"),
|
||||
pos,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +33,10 @@ impl Display for SassError {
|
||||
|
||||
impl From<io::Error> for SassError {
|
||||
fn from(error: io::Error) -> Self {
|
||||
SassError{ pos: Pos::new(), message: format!("{}", error) }
|
||||
SassError {
|
||||
pos: Pos::new(),
|
||||
message: format!("{}", error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,8 @@ mod test_scss {
|
||||
#[test]
|
||||
fn $func() {
|
||||
let mut buf = Vec::new();
|
||||
StyleSheet::new($input).expect(concat!("failed to parse on ", $input))
|
||||
StyleSheet::new($input)
|
||||
.expect(concat!("failed to parse on ", $input))
|
||||
.pretty_print(&mut buf)
|
||||
.expect(concat!("failed to pretty print on ", $input));
|
||||
assert_eq!(
|
||||
@ -112,7 +113,8 @@ mod test_scss {
|
||||
#[test]
|
||||
fn $func() {
|
||||
let mut buf = Vec::new();
|
||||
StyleSheet::new($input).expect(concat!("failed to parse on ", $input))
|
||||
StyleSheet::new($input)
|
||||
.expect(concat!("failed to parse on ", $input))
|
||||
.pretty_print(&mut buf)
|
||||
.expect(concat!("failed to pretty print on ", $input));
|
||||
assert_eq!(
|
||||
@ -216,6 +218,11 @@ mod test_scss {
|
||||
"$a: 1px;\n$b: $a; $a: 2px;\na {\n height: $b;\n}\n",
|
||||
"a {\n height: 1px;\n}\n"
|
||||
);
|
||||
test!(
|
||||
variable_shadowing_val_does_not_change_complex,
|
||||
"a {\n}\n$y: before;\n$x: 1 2 $y;\n$y: after;\nfoo {\n a: $x;\n}",
|
||||
"a {\n}\nfoo {\n a: 1 2 before;\n}\n"
|
||||
);
|
||||
test!(
|
||||
variable_whitespace,
|
||||
"$a : 1px ;\na {\n height: $a;\n}\n",
|
||||
@ -237,12 +244,22 @@ mod test_scss {
|
||||
"a {\n height: 1 1px;\n}\n"
|
||||
);
|
||||
|
||||
test!(
|
||||
removes_single_line_comment,
|
||||
"// a { color: red }\na {\n height: 1 1px;\n}\n",
|
||||
"a {\n height: 1 1px;\n}\n"
|
||||
);
|
||||
|
||||
test!(keyword_important, "a {\n height: 1 !important;\n}\n");
|
||||
test!(
|
||||
keyword_important_uppercase,
|
||||
"a {\n height: 1 !IMPORTANT;\n}\n",
|
||||
"a {\n height: 1 !important;\n}\n"
|
||||
);
|
||||
test!(
|
||||
keyword_important_not_at_end,
|
||||
"a {\n height: !important 1;\n}\n"
|
||||
);
|
||||
|
||||
test!(
|
||||
combines_hyphens,
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::common::Symbol;
|
||||
use crate::{Token, TokenKind};
|
||||
use std::fmt::{self, Display};
|
||||
use std::iter::Peekable;
|
||||
use std::slice::Iter;
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Selector {
|
||||
|
Loading…
x
Reference in New Issue
Block a user