Files
Steven Wroblewski fc8d5cb164 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>
2026-10-01 13:18:26 +02:00

28 lines
1.7 KiB
TOML

# 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" },
{ path = "std::collections::HashSet", reason = "iteration order differs between runs; use BTreeSet or Vec" },
{ path = "std::hash::RandomState", reason = "seeded differently in every run" },
{ path = "std::hash::DefaultHasher", reason = "seeded differently in every run" },
{ path = "std::time::Instant", reason = "the core must not read the clock" },
{ path = "std::time::SystemTime", reason = "the core must not read the clock" },
]
disallowed-methods = [
{ path = "std::env::var", reason = "the core must not depend on the environment" },
{ path = "std::env::args", reason = "the core must not depend on the environment" },
{ path = "std::thread::spawn", reason = "the core must stay single-threaded" },
{ path = "std::fs::read", reason = "the core must not touch files" },
{ path = "std::fs::read_to_string", reason = "the core must not touch files" },
{ path = "std::fs::write", reason = "the core must not touch files" },
{ path = "std::fs::File::open", reason = "the core must not touch files" },
{ path = "std::fs::File::create", reason = "the core must not touch files" },
{ path = "std::process::exit", reason = "the core must not end the process" },
]