Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,23 @@ jobs:
with:
command: fmt
args: --all -- --check

clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: clippy

- name: Run Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
2 changes: 1 addition & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod support {
}

pub(super) fn token<N: AstNode, T: AstToken>(parent: &N) -> Option<T> {
children_tokens(parent).nth(0)
children_tokens(parent).next()
}

/// Token untyped
Expand Down
2 changes: 1 addition & 1 deletion src/ast/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Comment {
pub fn text(&self) -> &str {
let text = self.syntax().text();
// Handle both "#..." and "/*...*/" comments.
match text.strip_prefix("#") {
match text.strip_prefix('#') {
Some(s) => s,
None => text.strip_prefix(r#"/*"#).unwrap().strip_suffix(r#"*/"#).unwrap(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<T: AstNode> Parse<T> {

/// Return all errors in the tree, if any
pub fn errors(&self) -> &[ParseError] {
&*self.errors
&self.errors
}

/// Either return the first error in the tree, or if there are none return self
Expand Down
12 changes: 6 additions & 6 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl Tokenizer<'_> {
}
Some('\\') => {
self.next().unwrap();
if let None = self.next() {
if self.next().is_none() {
return TOKEN_ERROR;
}
}
Expand Down Expand Up @@ -336,8 +336,8 @@ impl Tokenizer<'_> {
':' => TOKEN_COLON,
',' => TOKEN_COMMA,
'.' => {
if self.peek().map_or(false, |x| ('0'..='9').contains(&x)) {
self.consume(|c| ('0'..='9').contains(&c));
if self.peek().map_or(false, |x| x.is_ascii_digit()) {
self.consume(|c| c.is_ascii_digit());
self.consume_scientific()
} else {
TOKEN_DOT
Expand Down Expand Up @@ -436,10 +436,10 @@ impl Tokenizer<'_> {
TOKEN_STRING_START
}
'0'..='9' => {
self.consume(|c| ('0'..='9').contains(&c));
self.consume(|c| c.is_ascii_digit());
if self.peek() == Some('.') {
self.next().unwrap();
self.consume(|c| ('0'..='9').contains(&c));
self.consume(|c| c.is_ascii_digit());
self.consume_scientific()
} else {
TOKEN_INTEGER
Expand All @@ -455,7 +455,7 @@ impl Tokenizer<'_> {
if self.peek() == Some('-') || self.peek() == Some('+') {
self.next().unwrap();
}
if self.consume(|c| ('0'..='9').contains(&c)) == 0 {
if self.consume(|c| c.is_ascii_digit()) == 0 {
return TOKEN_ERROR;
}
}
Expand Down