Skip to content

Commit df009ee

Browse files
committed
Reformat
1 parent f48b2f6 commit df009ee

File tree

6 files changed

+24
-34
lines changed

6 files changed

+24
-34
lines changed

Cargo.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["xtask/", "lib/*", "crates/*"]
2+
members = ["xtask/", "lib/*", "lib/ungrammar/ungrammar2json", "crates/*"]
33
exclude = ["crates/proc-macro-srv/proc-macro-test/imp"]
44
resolver = "2"
55

@@ -42,7 +42,7 @@ debug = 2
4242
# lsp-server = { path = "lib/lsp-server" }
4343

4444

45-
# ungrammar = { path = "../ungrammar" }
45+
# ungrammar = { path = "lin/ungrammar" }
4646

4747
# salsa = { path = "../salsa" }
4848
# salsa-macros = { path = "../salsa/components/salsa-macros" }

lib/ungrammar/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ edition = "2018"
88

99
exclude = ["/bors.toml", "/.github"]
1010

11-
[workspace]
12-
members = ["ungrammar2json"]
1311

1412
[dependencies]
1513
# nope

lib/ungrammar/src/error.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ impl std::error::Error for Error {}
2727

2828
impl Error {
2929
pub(crate) fn with_location(self, location: Location) -> Error {
30-
Error {
31-
location: Some(location),
32-
..self
33-
}
30+
Error { location: Some(location), ..self }
3431
}
3532
}
3633

lib/ungrammar/src/parser.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Simple hand-written ungrammar parser.
2+
#![allow(clippy::disallowed_types)]
23
use std::collections::HashMap;
34

45
use crate::{
@@ -36,10 +37,7 @@ const DUMMY_RULE: Rule = Rule::Node(Node(!0));
3637
impl Parser {
3738
fn new(mut tokens: Vec<lexer::Token>) -> Parser {
3839
tokens.reverse();
39-
Parser {
40-
tokens,
41-
..Parser::default()
42-
}
40+
Parser { tokens, ..Parser::default() }
4341
}
4442

4543
fn peek(&self) -> Option<&lexer::Token> {
@@ -49,9 +47,7 @@ impl Parser {
4947
self.tokens.iter().nth_back(n)
5048
}
5149
fn bump(&mut self) -> Result<lexer::Token> {
52-
self.tokens
53-
.pop()
54-
.ok_or_else(|| format_err!("unexpected EOF"))
50+
self.tokens.pop().ok_or_else(|| format_err!("unexpected EOF"))
5551
}
5652
fn expect(&mut self, kind: TokenKind, what: &str) -> Result<()> {
5753
let token = self.bump()?;
@@ -75,10 +71,7 @@ impl Parser {
7571
let len = self.node_table.len();
7672
let grammar = &mut self.grammar;
7773
*self.node_table.entry(name.clone()).or_insert_with(|| {
78-
grammar.nodes.push(NodeData {
79-
name,
80-
rule: DUMMY_RULE,
81-
});
74+
grammar.nodes.push(NodeData { name, rule: DUMMY_RULE });
8275
Node(len)
8376
})
8477
}
@@ -127,11 +120,7 @@ fn rule(p: &mut Parser) -> Result<Rule> {
127120
let rule = seq_rule(p)?;
128121
alt.push(rule)
129122
}
130-
let res = if alt.len() == 1 {
131-
alt.pop().unwrap()
132-
} else {
133-
Rule::Alt(alt)
134-
};
123+
let res = if alt.len() == 1 { alt.pop().unwrap() } else { Rule::Alt(alt) };
135124
Ok(res)
136125
}
137126

@@ -142,11 +131,7 @@ fn seq_rule(p: &mut Parser) -> Result<Rule> {
142131
while let Some(rule) = opt_atom_rule(p)? {
143132
seq.push(rule)
144133
}
145-
let res = if seq.len() == 1 {
146-
seq.pop().unwrap()
147-
} else {
148-
Rule::Seq(seq)
149-
};
134+
let res = if seq.len() == 1 { seq.pop().unwrap() } else { Rule::Seq(seq) };
150135
Ok(res)
151136
}
152137

@@ -175,10 +160,7 @@ fn opt_atom_rule(p: &mut Parser) -> Result<Option<Rule>> {
175160
p.bump()?;
176161
p.bump()?;
177162
let rule = atom_rule(p)?;
178-
let res = Rule::Labeled {
179-
label,
180-
rule: Box::new(rule),
181-
};
163+
let res = Rule::Labeled { label, rule: Box::new(rule) };
182164
return Ok(Some(res));
183165
}
184166
_ => (),

lib/ungrammar/ungrammar2json/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::print_stderr, clippy::print_stdout)]
12
use std::{
23
env,
34
io::{self, Read},

0 commit comments

Comments
 (0)