Textwächter erkennt gruppierte std-Importe und globale Sperren

Mit `use std::{fs, process};` und anschließendem `fs::remove_file(…)`
kam bisher beides durch: Der Textwächter suchte `std::fs` wörtlich, und
Clippy kennt nur die aufgelisteten Funktionen. Globaler veränderlicher
Zustand über `static` mit Mutex, RwLock, OnceLock oder LazyLock wurde
auch nicht erkannt.

Neu in FORBIDDEN: `std::{` (gruppierte Importe verbergen dem Text die
Modulnamen) sowie Mutex, RwLock, OnceLock und LazyLock. Der Kern in
core/src nutzt nichts davon. Der Kommentar in core/clippy.toml behauptet
jetzt nur noch, was Clippy leistet, und CLAUDE.md nennt die Regel, dass
jeder std-Pfad in einer eigenen use-Zeile steht.

Der bestehende Selbsttest every_forbidden_term_is_detected deckt die
neuen Einträge ab.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Steven Wroblewski
2026-10-01 13:18:26 +02:00
parent 842213c574
commit fc8d5cb164
3 changed files with 15 additions and 4 deletions
+6 -3
View File
@@ -1,6 +1,9 @@
# Paths the deterministic core must never use. Clippy resolves imports, so
# aliases and grouped imports such as `use std::{fs, env}` are caught too.
# The text search in core/tests/forbidden_apis.rs covers the rest.
# Paths the deterministic core must never use. Clippy resolves paths, so a
# listed path is caught under an alias or in a grouped import as well, for
# example `fs::read` after `use std::{fs, env}`. Only the paths listed below
# are checked. Everything else is the job of the text search in
# core/tests/forbidden_apis.rs, which forbids grouped imports from `std`
# because they hide module names from it.
disallowed-types = [
{ path = "std::collections::HashMap", reason = "iteration order differs between runs; use BTreeMap or Vec" },
+8
View File
@@ -42,12 +42,20 @@ const FORBIDDEN: &[(&str, &str)] = &[
"the core must not read or write streams; the shell does that",
),
("std::process", "the core must not start or end processes"),
(
"std::{",
"grouped std imports hide forbidden modules from this search; import each path on its own line",
),
("static mut", "global mutable state can differ between runs"),
(
"thread_local",
"global mutable state can differ between runs",
),
("Atomic", "global mutable state can differ between runs"),
("Mutex", "global mutable state can differ between runs"),
("RwLock", "global mutable state can differ between runs"),
("OnceLock", "global mutable state can differ between runs"),
("LazyLock", "global mutable state can differ between runs"),
("unsafe", "the core forbids unsafe code"),
];