Skip to content

Commit be00563

Browse files
authored
squawk_syntax: fix ast::BinExpr (#634)
also fix codegen formatting
1 parent b571e59 commit be00563

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

crates/squawk/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use squawk_linter::{Rule, Version};
1111
use structopt::clap::arg_enum;
1212

1313
use crate::file_finding::find_paths;
14-
use std::io::IsTerminal;
1514
use config::Config;
1615
use log::info;
1716
use simplelog::CombinedLogger;
1817
use std::io;
18+
use std::io::IsTerminal;
1919
use std::panic;
2020
use std::path::PathBuf;
2121
use std::process::{self, ExitCode};

crates/squawk_syntax/src/ast/generated/nodes.rs

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/squawk_syntax/src/ast/node_ext.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ impl ast::Constraint {
4141
}
4242
}
4343

44+
impl ast::BinExpr {
45+
pub fn lhs(&self) -> Option<ast::Expr> {
46+
support::children(self.syntax()).next()
47+
}
48+
49+
pub fn rhs(&self) -> Option<ast::Expr> {
50+
support::children(self.syntax()).nth(1)
51+
}
52+
}
53+
4454
impl ast::NameRef {
4555
#[inline]
4656
pub fn text(&self) -> TokenText<'_> {

crates/xtask/src/codegen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn ensure_rustfmt(sh: &Shell) {
5151
fn reformat(text: String) -> String {
5252
let sh = Shell::new().unwrap();
5353
ensure_rustfmt(&sh);
54-
let mut stdout = cmd!(sh, "rustup run stable rustfmt")
54+
let mut stdout = cmd!(sh, "rustup run stable rustfmt --edition=2024")
5555
.stdin(text)
5656
.read()
5757
.unwrap();
@@ -624,7 +624,7 @@ fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, label: Option<&String>, r
624624
}
625625
Rule::Labeled { label: l, rule } => {
626626
assert!(label.is_none());
627-
let manually_implemented = matches!(l.as_str(), "value");
627+
let manually_implemented = matches!(l.as_str(), "value" | "lhs" | "rhs");
628628
if manually_implemented {
629629
return;
630630
}

0 commit comments

Comments
 (0)