Replace lexical Rust fragments with real modules
This commit is contained in:
parent
f8849cdb5f
commit
247819250b
1 changed files with 3302 additions and 2671 deletions
|
|
@ -386,7 +386,7 @@ def process_lint_allowances(relative: str, source: str) -> set[str]:
|
|||
)
|
||||
following = source[exemption.end() : exemption.end() + 400]
|
||||
function = re.match(
|
||||
r"\s*\)\s*\]\s*(?:#\[[^]]+\]\s*)*(?:pub\s+)?fn\s+([A-Za-z0-9_]+)\s*[<(]",
|
||||
r"\s*\)\s*\]\s*(?:#\[[^]]+\]\s*)*(?:pub(?:\([^)]*\))?\s+)?fn\s+([A-Za-z0-9_]+)\s*[<(]",
|
||||
following,
|
||||
)
|
||||
require(function is not None, f"non-function process lint exemption: {relative}")
|
||||
|
|
@ -416,6 +416,20 @@ def workspace_rust_sources(metadata: dict) -> list[Path]:
|
|||
return sorted(sources)
|
||||
|
||||
|
||||
def audit_rust_module_boundaries(metadata: dict) -> None:
|
||||
included = []
|
||||
for path in workspace_rust_sources(metadata):
|
||||
source = path.read_text()
|
||||
if re.search(r"(?m)^\s*include!\s*\(", source):
|
||||
included.append(str(path.relative_to(ROOT)))
|
||||
require(
|
||||
not included,
|
||||
"Rust source uses lexical include! instead of a module boundary: "
|
||||
+ ", ".join(included),
|
||||
)
|
||||
print("PASS Rust module boundaries")
|
||||
|
||||
|
||||
def audit_rust_file_sizes(metadata: dict) -> None:
|
||||
sources = workspace_rust_sources(metadata)
|
||||
relative_sources = {str(path.relative_to(ROOT)): path for path in sources}
|
||||
|
|
@ -720,6 +734,7 @@ def verify(process_syscalls: bool) -> None:
|
|||
run_ignored_workspace_corpus(metadata)
|
||||
run([sys.executable, "-m", "unittest", "discover", "-s", "tests/tooling"])
|
||||
audit_workspace_lints(metadata)
|
||||
audit_rust_module_boundaries(metadata)
|
||||
audit_rust_file_sizes(metadata)
|
||||
audit_dependencies(metadata)
|
||||
run_models()
|
||||
|
|
|
|||
Loading…
Reference in a new issue