v0.1.0-pre.015

This commit is contained in:
2026-07-24 17:25:51 +02:00
parent 60a75c4434
commit a818c4a60e
26 changed files with 16723 additions and 103 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# file: scripts/audit_rust_general_rules.py
# version: 7
# version: 8
"""Audit mechanically verifiable Rust rules shared by all Rust projects."""
@@ -116,6 +116,10 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
previous_export_visibility: str | None = None
previous_export_key: tuple[object, ...] | None = None
blank_since_export = False
crate_visibility_seen = False
enforce_visibility_order = relative == "kb-lib/src/lib.rs" or relative.startswith(
"kb-lib/src/executor"
)
for index, line in enumerate(lines, 1):
if not line.strip():
if previous_export_line is not None:
@@ -125,6 +129,32 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
continue
if line.startswith("pub use ") or line.startswith("pub(crate) use "):
visibility = "pub(crate)" if line.startswith("pub(crate) use ") else "pub"
if enforce_visibility_order and visibility == "pub" and crate_visibility_seen:
violations.append(
Violation(
"RUST024",
relative,
index,
"`pub use` block must precede the `pub(crate) use` block",
)
)
if visibility == "pub(crate)":
crate_visibility_seen = True
if (
enforce_visibility_order
and
previous_export_line is not None
and previous_export_visibility != visibility
and not blank_since_export
):
violations.append(
Violation(
"RUST025",
relative,
index,
"re-export blocks with different visibility require one empty line",
)
)
if (
previous_export_line is not None
and previous_export_visibility == visibility