use crate::Strictness;
pub struct AnnotationInfo {
pub name: &'static str,
pub params: &'static str,
pub purpose: &'static str,
pub spec_ref: Option<&'static str>,
}
pub struct StrictnessLevelInfo {
pub name: &'static str,
pub description: &'static str,
pub spec_ref: Option<&'static str>,
}
#[must_use]
pub fn annotations() -> Vec<AnnotationInfo> {
vec![
AnnotationInfo {
name: "managed",
params: "",
purpose: "Suppress ownership and move-checking for the annotated item.",
spec_ref: Some("§3.6"),
},
AnnotationInfo {
name: "derive",
params: "trait,...",
purpose: "Auto-derive trait implementations for a record or enum.",
spec_ref: Some("§4.7"),
},
AnnotationInfo {
name: "test",
params: "",
purpose: "Mark a function as a unit test discovered by `bock test`.",
spec_ref: Some("§16.2"),
},
AnnotationInfo {
name: "requires",
params: "capability,...",
purpose: "Declare the capabilities this function requires.",
spec_ref: Some("§9"),
},
AnnotationInfo {
name: "performance",
params: "max_latency, max_allocations",
purpose: "Declare performance budgets enforced by the context pass.",
spec_ref: Some("§9"),
},
]
}
#[must_use]
pub fn strictness_levels() -> Vec<StrictnessLevelInfo> {
vec![
StrictnessLevelInfo {
name: "sketch",
description: "Lenient mode: effects and capabilities are inferred; no diagnostics.",
spec_ref: Some("§8.4"),
},
StrictnessLevelInfo {
name: "development",
description: "Public items must declare effects; private items are not checked.",
spec_ref: Some("§8.4"),
},
StrictnessLevelInfo {
name: "production",
description: "Every function must declare its effects and capabilities.",
spec_ref: Some("§8.4"),
},
]
}
#[must_use]
pub fn strictness_name(level: Strictness) -> &'static str {
match level {
Strictness::Sketch => "sketch",
Strictness::Development => "development",
Strictness::Production => "production",
}
}