diff --git a/crates/squawk/src/main.rs b/crates/squawk/src/main.rs index 9ff9b76a..cbe8a9ee 100644 --- a/crates/squawk/src/main.rs +++ b/crates/squawk/src/main.rs @@ -11,11 +11,11 @@ use squawk_linter::{Rule, Version}; use structopt::clap::arg_enum; use crate::file_finding::find_paths; -use std::io::IsTerminal; use config::Config; use log::info; use simplelog::CombinedLogger; use std::io; +use std::io::IsTerminal; use std::panic; use std::path::PathBuf; use std::process::{self, ExitCode}; diff --git a/crates/squawk_syntax/src/ast/generated/nodes.rs b/crates/squawk_syntax/src/ast/generated/nodes.rs index 0ec92287..c6e36d00 100644 --- a/crates/squawk_syntax/src/ast/generated/nodes.rs +++ b/crates/squawk_syntax/src/ast/generated/nodes.rs @@ -1347,18 +1347,10 @@ pub struct BinExpr { pub(crate) syntax: SyntaxNode, } impl BinExpr { - #[inline] - pub fn lhs(&self) -> Option { - support::child(&self.syntax) - } #[inline] pub fn op(&self) -> Option { support::child(&self.syntax) } - #[inline] - pub fn rhs(&self) -> Option { - support::child(&self.syntax) - } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/crates/squawk_syntax/src/ast/node_ext.rs b/crates/squawk_syntax/src/ast/node_ext.rs index 7dffb972..f42f4ae9 100644 --- a/crates/squawk_syntax/src/ast/node_ext.rs +++ b/crates/squawk_syntax/src/ast/node_ext.rs @@ -41,6 +41,16 @@ impl ast::Constraint { } } +impl ast::BinExpr { + pub fn lhs(&self) -> Option { + support::children(self.syntax()).next() + } + + pub fn rhs(&self) -> Option { + support::children(self.syntax()).nth(1) + } +} + impl ast::NameRef { #[inline] pub fn text(&self) -> TokenText<'_> { diff --git a/crates/xtask/src/codegen.rs b/crates/xtask/src/codegen.rs index dcaaf7b1..61b2c58a 100644 --- a/crates/xtask/src/codegen.rs +++ b/crates/xtask/src/codegen.rs @@ -51,7 +51,7 @@ fn ensure_rustfmt(sh: &Shell) { fn reformat(text: String) -> String { let sh = Shell::new().unwrap(); ensure_rustfmt(&sh); - let mut stdout = cmd!(sh, "rustup run stable rustfmt") + let mut stdout = cmd!(sh, "rustup run stable rustfmt --edition=2024") .stdin(text) .read() .unwrap(); @@ -624,7 +624,7 @@ fn lower_rule(acc: &mut Vec, grammar: &Grammar, label: Option<&String>, r } Rule::Labeled { label: l, rule } => { assert!(label.is_none()); - let manually_implemented = matches!(l.as_str(), "value"); + let manually_implemented = matches!(l.as_str(), "value" | "lhs" | "rhs"); if manually_implemented { return; }