Normalize whole tree with cargo fmt under rustfmt.toml

One-time mechanical pass; no behavior change (full test suite green
before and after). From here on, cargo fmt --check is the standard.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-18 23:41:18 -07:00
1 parent 8effef9b6b
commit d2cd44c428
8 files changed
+191 -149

No files matched your search

+32 -19
View File
@@ -27,13 +27,26 @@ impl std::error::Error for ParseError {}
type PResult<T> = Result<T, ParseError>;
const TYPE_KEYWORDS: &[&str] = &[
"logic", "reg", "bit", "byte", "shortint", "int", "longint", "integer", "time", "realtime",
"real", "shortreal", "string", "chandle", "event", "void",
"logic",
"reg",
"bit",
"byte",
"shortint",
"int",
"longint",
"integer",
"time",
"realtime",
"real",
"shortreal",
"string",
"chandle",
"event",
"void",
];
const NET_KEYWORDS: &[&str] = &[
"wire", "tri", "tri0", "tri1", "wand", "wor", "trireg", "supply0", "supply1", "uwire",
];
const NET_KEYWORDS: &[&str] =
&["wire", "tri", "tri0", "tri1", "wand", "wor", "trireg", "supply0", "supply1", "uwire"];
const GATE_KEYWORDS: &[&str] = &[
"and", "or", "nand", "nor", "xor", "xnor", "not", "buf", "bufif0", "bufif1", "notif0",
@@ -41,9 +54,8 @@ const GATE_KEYWORDS: &[&str] = &[
"rtran", "tranif0", "tranif1", "rtranif0", "rtranif1",
];
const ASSIGN_OPS: &[&str] = &[
"=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "<<<=", ">>>=",
];
const ASSIGN_OPS: &[&str] =
&["=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "<<<=", ">>>="];
pub struct Parser {
tokens: Vec<Token>,
@@ -53,7 +65,8 @@ pub struct Parser {
}
pub fn parse(tokens: Vec<Token>) -> PResult<SourceFile> {
let mut p = Parser { tokens, pos: 0, pending_leading: Vec::new(), pending_trailing: Vec::new() };
let mut p =
Parser { tokens, pos: 0, pending_leading: Vec::new(), pending_trailing: Vec::new() };
p.parse_source_file()
}
@@ -319,8 +332,10 @@ impl Parser {
}
_ if NET_KEYWORDS.contains(&kw.as_str())
|| TYPE_KEYWORDS.contains(&kw.as_str())
|| matches!(kw.as_str(), "var" | "automatic" | "static" | "const" | "signed"
| "unsigned") =>
|| matches!(
kw.as_str(),
"var" | "automatic" | "static" | "const" | "signed" | "unsigned"
) =>
{
let d = self.parse_data_decl()?;
Ok(ItemKind::DataDecl(d))
@@ -647,7 +662,9 @@ impl Parser {
let t = self.cur();
if t.kind == TokenKind::Keyword && NET_KEYWORDS.contains(&t.text.as_str()) {
net = Some(self.bump().text);
} else if t.is_kw("var") || t.is_kw("automatic") || t.is_kw("static")
} else if t.is_kw("var")
|| t.is_kw("automatic")
|| t.is_kw("static")
|| t.is_kw("const")
{
qualifiers.push(self.bump().text);
@@ -1398,11 +1415,8 @@ impl Parser {
(None, Some(Box::new(self.parse_stmt()?)))
} else {
let then = Box::new(self.parse_stmt()?);
let els = if self.eat_kw("else") {
Some(Box::new(self.parse_stmt()?))
} else {
None
};
let els =
if self.eat_kw("else") { Some(Box::new(self.parse_stmt()?)) } else { None };
(Some(then), els)
};
Ok(StmtKind::Assert { kw, cond, then, els })
@@ -1495,8 +1509,7 @@ impl Parser {
fn parse_for_step(&mut self) -> PResult<ForStep> {
let lhs = self.parse_unary()?;
let op = self.cur().text.clone();
if self.cur().kind == TokenKind::Symbol
&& (ASSIGN_OPS.contains(&op.as_str()) || op == "<=")
if self.cur().kind == TokenKind::Symbol && (ASSIGN_OPS.contains(&op.as_str()) || op == "<=")
{
self.bump();
let rhs = self.parse_expr()?;