Skip to content
Merged
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
6 changes: 3 additions & 3 deletions treeedb/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ fn handle_parse_errors(path: &str, tree: &Tree, on_parse_error: &OnParseError) {
OnParseError::Warn if !node.has_error() => (),
OnParseError::Error if !node.has_error() => (),
OnParseError::Warn => {
eprintln!("[warn] Parse error in {}", path);
eprintln!("[warn] Parse error in {path}");
}
OnParseError::Error => {
eprintln!("[error] Parse error in {}", path);
eprintln!("[error] Parse error in {path}");
process::exit(1);
}
}
Expand All @@ -58,7 +58,7 @@ pub struct Args {
}

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

fn parse(language: tree_sitter::Language, code: &str) -> Result<Tree> {
Expand Down
2 changes: 1 addition & 1 deletion treeedbgen-souffle/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn main(node_types: &str) -> Result<()> {
};
if let Some(path) = args.output {
let mut file = std::fs::File::create(&path)
.with_context(|| format!("Failed to write to file {}", path))?;
.with_context(|| format!("Failed to write to file {path}"))?;
super::r#gen(&config, &mut file, node_types)?;
} else {
// https://nnethercote.github.io/perf-book/io.html#locking
Expand Down
10 changes: 7 additions & 3 deletions treeedbgen-souffle/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ fn node_with_fields(
w: &mut impl Write,
node: &Node,
) -> Result<String, io::Error> {
let rel_name = &node.ty;
let rel_name = match node.ty.as_str() {
"true" => "true_literal",
"false" => "false_literal",
_ => &node.ty,
};
let type_name = node.ty.to_upper_camel_case();
writeln!(w, ".type {}{} <: symbol", config.type_prefix, type_name)?;
writeln!(
Expand Down Expand Up @@ -55,7 +59,7 @@ fn node_with_fields(
node.ty.to_upper_camel_case(),
field_name.to_upper_camel_case(),
);
write!(w, ".type {} = ", field_type_name)?;
write!(w, ".type {field_type_name} = ")?;
let mut types = Vec::new();
for t in &field.types {
if t.named {
Expand Down Expand Up @@ -189,7 +193,7 @@ impl PrivGenConfig {
PrivGenConfig {
printsize: config.printsize,
relation_prefix: if let Some(pfx) = &config.prefix {
format!("{}_", pfx)
format!("{pfx}_")
} else {
"".to_owned()
},
Expand Down
Loading