Skip to content

Commit 15469be

Browse files
Added suffix '_literal' to boolean literals (#196)
Also fix clippy lints
1 parent eaa77e3 commit 15469be

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

treeedb/src/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ fn handle_parse_errors(path: &str, tree: &Tree, on_parse_error: &OnParseError) {
3232
OnParseError::Warn if !node.has_error() => (),
3333
OnParseError::Error if !node.has_error() => (),
3434
OnParseError::Warn => {
35-
eprintln!("[warn] Parse error in {}", path);
35+
eprintln!("[warn] Parse error in {path}");
3636
}
3737
OnParseError::Error => {
38-
eprintln!("[error] Parse error in {}", path);
38+
eprintln!("[error] Parse error in {path}");
3939
process::exit(1);
4040
}
4141
}
@@ -58,7 +58,7 @@ pub struct Args {
5858
}
5959

6060
fn read_file(file: &str) -> Result<String> {
61-
fs::read_to_string(file).with_context(|| format!("Failed to read file {}", file))
61+
fs::read_to_string(file).with_context(|| format!("Failed to read file {file}"))
6262
}
6363

6464
fn parse(language: tree_sitter::Language, code: &str) -> Result<Tree> {

treeedbgen-souffle/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn main(node_types: &str) -> Result<()> {
2626
};
2727
if let Some(path) = args.output {
2828
let mut file = std::fs::File::create(&path)
29-
.with_context(|| format!("Failed to write to file {}", path))?;
29+
.with_context(|| format!("Failed to write to file {path}"))?;
3030
super::r#gen(&config, &mut file, node_types)?;
3131
} else {
3232
// https://nnethercote.github.io/perf-book/io.html#locking

treeedbgen-souffle/src/gen.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ fn node_with_fields(
1616
w: &mut impl Write,
1717
node: &Node,
1818
) -> Result<String, io::Error> {
19-
let rel_name = &node.ty;
19+
let rel_name = match node.ty.as_str() {
20+
"true" => "true_literal",
21+
"false" => "false_literal",
22+
_ => &node.ty,
23+
};
2024
let type_name = node.ty.to_upper_camel_case();
2125
writeln!(w, ".type {}{} <: symbol", config.type_prefix, type_name)?;
2226
writeln!(
@@ -55,7 +59,7 @@ fn node_with_fields(
5559
node.ty.to_upper_camel_case(),
5660
field_name.to_upper_camel_case(),
5761
);
58-
write!(w, ".type {} = ", field_type_name)?;
62+
write!(w, ".type {field_type_name} = ")?;
5963
let mut types = Vec::new();
6064
for t in &field.types {
6165
if t.named {
@@ -189,7 +193,7 @@ impl PrivGenConfig {
189193
PrivGenConfig {
190194
printsize: config.printsize,
191195
relation_prefix: if let Some(pfx) = &config.prefix {
192-
format!("{}_", pfx)
196+
format!("{pfx}_")
193197
} else {
194198
"".to_owned()
195199
},

0 commit comments

Comments
 (0)