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 semantic 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 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 modules of crate '{crate_package}' (declared via `mod`) — check the path"
)
}
pub(crate) fn unknown_trait_error(trait_path: &str, crate_package: &str) -> String {
format!(
"a trait-impl-locality boundary must anchor to a real local trait or it silently never \
reacts: trait '{trait_path}' is not found as a `trait` item (directly or via a local \
`pub use`) in crate '{crate_package}' — check the path"
)
}
pub(crate) fn unsafe_empty_allowed_error(crate_package: &str) -> String {
format!(
"an unsafe-confinement boundary on crate '{crate_package}' declares an empty `only_under([])`: \
this rule confines `unsafe` to a subtree, it does not ban it crate-wide — for that use \
`#![forbid(unsafe_code)]` (compile-time, unbypassable); name at least one allowed subtree"
)
}
pub(crate) fn unsafe_crate_root_allowed_error(crate_package: &str) -> String {
format!(
"an unsafe-confinement boundary on crate '{crate_package}' allows `unsafe` under `crate` \
(the crate root): the whole crate would be permitted, so the rule could never react — \
confine it to a submodule (e.g. `crate::ffi`) instead"
)
}
pub(crate) fn missing_module_file_error(module: &str, crate_package: &str) -> String {
format!(
"module '{module}' of crate '{crate_package}' is declared (`mod …;`) but its source file \
could not be located (expected `<name>.rs` or `<name>/mod.rs`)"
)
}
pub(crate) fn unreadable_source_error(file: &Path, err: &str) -> String {
format!("cannot read source file '{}': {err}", file.display())
}
pub(crate) fn unparseable_source_error(file: &Path, err: &str) -> String {
format!("cannot parse source file '{}': {err}", file.display())
}