summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-11-15 16:59:49 +0100
committerLaurenz <laurmaedje@gmail.com>2021-11-15 17:06:43 +0100
commit63c274e7f6aa3a8c3f43abb91935ec924a186f73 (patch)
tree193777ff773c6b547c6ef828ddf9750694fae7bc /src/parse
parent8a38899c98b4f9829b2d1f21c8fee66d254d20c6 (diff)
Make clippy happier and remove `Str`
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/parser.rs14
-rw-r--r--src/parse/scanner.rs2
-rw-r--r--src/parse/tokens.rs28
3 files changed, 20 insertions, 24 deletions
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index 1c4c2a5c..6598b1f2 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -242,7 +242,7 @@ impl<'s> Parser<'s> {
self.eat();
rescan = false;
} else if required {
- self.push_error(format!("expected {}", end));
+ self.push_error(format_eco!("expected {}", end));
}
}
@@ -327,8 +327,8 @@ impl Parser<'_> {
pub fn unexpected(&mut self) {
match self.peek() {
Some(found) => {
- let msg = format!("unexpected {}", found);
- let error = NodeKind::Error(ErrorPos::Full, msg.into());
+ let msg = format_eco!("unexpected {}", found);
+ let error = NodeKind::Error(ErrorPos::Full, msg);
self.perform(error, Self::eat);
}
None => self.push_error("unexpected end of file"),
@@ -339,8 +339,8 @@ impl Parser<'_> {
pub fn expected(&mut self, thing: &str) {
match self.peek() {
Some(found) => {
- let msg = format!("expected {}, found {}", thing, found);
- let error = NodeKind::Error(ErrorPos::Full, msg.into());
+ let msg = format_eco!("expected {}, found {}", thing, found);
+ let error = NodeKind::Error(ErrorPos::Full, msg);
self.perform(error, Self::eat);
}
None => self.expected_at(thing),
@@ -400,8 +400,8 @@ impl Marker {
/// Insert an error message that `what` was expected at the marker position.
pub fn expected(self, p: &mut Parser, what: &str) {
- let msg = format!("expected {}", what);
- let error = NodeKind::Error(ErrorPos::Full, msg.into());
+ let msg = format_eco!("expected {}", what);
+ let error = NodeKind::Error(ErrorPos::Full, msg);
p.children.insert(self.0, GreenData::new(error, 0).into());
}
diff --git a/src/parse/scanner.rs b/src/parse/scanner.rs
index ea06a2e0..c735be40 100644
--- a/src/parse/scanner.rs
+++ b/src/parse/scanner.rs
@@ -119,7 +119,7 @@ impl<'s> Scanner<'s> {
/// The full source string.
#[inline]
pub fn src(&self) -> &'s str {
- &self.src
+ self.src
}
/// Slice out part of the source string.
diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs
index 96dfd9d1..f80d345e 100644
--- a/src/parse/tokens.rs
+++ b/src/parse/tokens.rs
@@ -239,7 +239,7 @@ impl<'s> Tokens<'s> {
self.s.eat_assert('{');
let sequence = self.s.eat_while(|c| c.is_ascii_alphanumeric());
if self.s.eat_if('}') {
- if let Some(c) = resolve_hex(&sequence) {
+ if let Some(c) = resolve_hex(sequence) {
NodeKind::UnicodeEscape(c)
} else {
NodeKind::Error(
@@ -270,7 +270,7 @@ impl<'s> Tokens<'s> {
None => NodeKind::Ident(read.into()),
}
} else {
- NodeKind::Text("#".into())
+ NodeKind::Text('#'.into())
}
}
@@ -284,7 +284,7 @@ impl<'s> Tokens<'s> {
} else if self.s.check_or(true, char::is_whitespace) {
NodeKind::Minus
} else {
- NodeKind::Text("-".into())
+ NodeKind::Text('-'.into())
}
}
@@ -340,7 +340,7 @@ impl<'s> Tokens<'s> {
NodeKind::Raw(Rc::new(resolve_raw(
column,
backticks,
- self.s.get(start .. end).into(),
+ self.s.get(start .. end),
)))
} else {
let remaining = backticks - found;
@@ -349,11 +349,10 @@ impl<'s> Tokens<'s> {
NodeKind::Error(
ErrorPos::End,
if found == 0 {
- format!("expected {} {}", remaining, noun)
+ format_eco!("expected {} {}", remaining, noun)
} else {
- format!("expected {} more {}", remaining, noun)
- }
- .into(),
+ format_eco!("expected {} more {}", remaining, noun)
+ },
)
}
}
@@ -397,11 +396,10 @@ impl<'s> Tokens<'s> {
NodeKind::Error(
ErrorPos::End,
if !display || (!escaped && dollar) {
- "expected closing dollar sign"
+ "expected closing dollar sign".into()
} else {
- "expected closing bracket and dollar sign"
- }
- .into(),
+ "expected closing bracket and dollar sign".into()
+ },
)
}
}
@@ -413,7 +411,7 @@ impl<'s> Tokens<'s> {
"auto" => NodeKind::Auto,
"true" => NodeKind::Bool(true),
"false" => NodeKind::Bool(false),
- id => keyword(id).unwrap_or(NodeKind::Ident(id.into())),
+ id => keyword(id).unwrap_or_else(|| NodeKind::Ident(id.into())),
}
}
@@ -461,9 +459,7 @@ impl<'s> Tokens<'s> {
"in" => NodeKind::Length(f, LengthUnit::In),
"deg" => NodeKind::Angle(f, AngularUnit::Deg),
"rad" => NodeKind::Angle(f, AngularUnit::Rad),
- _ => {
- return NodeKind::Unknown(all.into());
- }
+ _ => NodeKind::Unknown(all.into()),
}
} else {
NodeKind::Unknown(all.into())