use std::path::Path;
pub(crate) fn unreadable_workspace_error(manifest_path: &Path, err: &str) -> String {
format!(
"a boundary is observed against a real workspace, so an unreadable one cannot be judged \
and its verdict would be a false pass: cannot read target workspace at {} ({err}); check \
the manifest path and that `cargo metadata` succeeds",
manifest_path.display()
)
}
pub(crate) fn crate_not_found_error(crate_package: &str) -> String {
format!(
"a boundary must govern a real crate or it silently never reacts: target crate \
'{crate_package}' is not a member of the target workspace — check the name or --manifest-path"
)
}
pub(crate) fn missing_src_error(crate_package: &str) -> String {
format!(
"a module boundary is observed from source, so with no src it could never react: cannot \
locate the crate root source for '{crate_package}'"
)
}
pub(crate) fn inline_module_target_error(module: &str, crate_package: &str, leaf: &str) -> String {
format!(
"module '{module}' in crate '{crate_package}' is declared inline (`mod {leaf} {{ … }}`) and \
owns no source file; module boundaries govern file-based modules — move it \
into its own file (e.g. `src/{leaf}.rs`), or target an enclosing file-based \
module"
)
}
pub(crate) fn unknown_module_error(module: &str, crate_package: &str) -> String {
format!(
"a boundary must anchor to a real module or it silently never reacts: module '{module}' is \
not found among the reachable modules of crate '{crate_package}' (declared via `mod`, \
file-based) — check the path"
)
}
pub(crate) fn restrict_imports_to_on_crate_error(crate_package: &str) -> String {
format!(
"the `restrict_imports_to` rule cannot govern `crate` (the crate root) of crate \
'{crate_package}': the root has no outward internal edge — every internal import is \
within its own subtree, so the rule could never react; declare it on a submodule \
(e.g. `crate::kernel`) instead"
)
}
pub(crate) fn must_not_be_imported_by_on_crate_error(crate_package: &str) -> String {
format!(
"the `must_not_be_imported_by` rule cannot protect `crate` (the crate root) of crate \
'{crate_package}': every internal import is within the crate root, so the rule could \
never react as an inbound rule; declare it on a submodule (e.g. `crate::internal`) \
instead"
)
}
pub(crate) fn must_only_be_imported_by_on_crate_error(crate_package: &str) -> String {
format!(
"the `must_only_be_imported_by` rule cannot protect `crate` (the crate root) of crate \
'{crate_package}': every module is within the crate root, so none is an inbound importer \
and the allowlist could never react; declare it on a submodule (e.g. `crate::internal`) \
instead"
)
}
pub(crate) fn confine_external_crate_on_crate_error(crate_package: &str) -> String {
format!(
"the `confine_external_crate` rule cannot confine a crate to `crate` (the crate root) of \
crate '{crate_package}': the root's subtree is the whole crate, so the confined crate \
would be permitted everywhere and the rule could never react; confine it to a submodule \
(e.g. `crate::ffi`) instead"
)
}
pub(crate) fn inline_empty_prefix_error(crate_package: &str) -> String {
format!(
"the `must_not_call_inline` rule needs a non-empty module-path prefix (e.g. `std::time`) \
to confine, in crate '{crate_package}': an empty prefix cannot name a surface, so the \
rule could never react meaningfully"
)
}
pub(crate) fn inline_empty_verbs_error(crate_package: &str) -> String {
format!(
"a `must_not_call_inline` boundary in crate '{crate_package}' declares `.ending_with([])` \
with an empty verb set, which would react on nothing (a silent no-op); pass at least one \
read verb (e.g. `[\"now\"]`) or drop the narrowing"
)
}
pub(crate) fn inline_narrow_and_strict_error(crate_package: &str) -> String {
format!(
"a `must_not_call_inline` boundary in crate '{crate_package}' declares both `.ending_with(…)` \
and `.strict_prefix_only()`, which contradict (narrow to read verbs vs. widen to all \
mentions); choose one"
)
}
pub(crate) fn unreadable_governed_file_error(file: &Path, err: &str) -> String {
format!(
"a governed file that cannot be read is 'cannot judge', not 'nothing to judge' — skipping \
it could hide a real violation: cannot read governed source file '{}' ({err})",
file.display()
)
}