1use crate::Strictness;
7
8pub struct AnnotationInfo {
10 pub name: &'static str,
12 pub params: &'static str,
14 pub purpose: &'static str,
16 pub spec_ref: Option<&'static str>,
18}
19
20pub struct StrictnessLevelInfo {
22 pub name: &'static str,
24 pub description: &'static str,
26 pub spec_ref: Option<&'static str>,
28}
29
30#[must_use]
32pub fn annotations() -> Vec<AnnotationInfo> {
33 vec![
34 AnnotationInfo {
35 name: "managed",
36 params: "",
37 purpose: "Suppress ownership and move-checking for the annotated item.",
38 spec_ref: Some("§3.6"),
39 },
40 AnnotationInfo {
41 name: "derive",
42 params: "trait,...",
43 purpose: "Auto-derive trait implementations for a record or enum.",
44 spec_ref: Some("§4.7"),
45 },
46 AnnotationInfo {
47 name: "test",
48 params: "",
49 purpose: "Mark a function as a unit test discovered by `bock test`.",
50 spec_ref: Some("§16.2"),
51 },
52 AnnotationInfo {
53 name: "requires",
54 params: "capability,...",
55 purpose: "Declare the capabilities this function requires.",
56 spec_ref: Some("§9"),
57 },
58 AnnotationInfo {
59 name: "performance",
60 params: "max_latency, max_allocations",
61 purpose: "Declare performance budgets enforced by the context pass.",
62 spec_ref: Some("§9"),
63 },
64 ]
65}
66
67#[must_use]
69pub fn strictness_levels() -> Vec<StrictnessLevelInfo> {
70 vec![
71 StrictnessLevelInfo {
72 name: "sketch",
73 description: "Lenient mode: effects and capabilities are inferred; no diagnostics.",
74 spec_ref: Some("§8.4"),
75 },
76 StrictnessLevelInfo {
77 name: "development",
78 description: "Public items must declare effects; private items are not checked.",
79 spec_ref: Some("§8.4"),
80 },
81 StrictnessLevelInfo {
82 name: "production",
83 description: "Every function must declare its effects and capabilities.",
84 spec_ref: Some("§8.4"),
85 },
86 ]
87}
88
89#[must_use]
91pub fn strictness_name(level: Strictness) -> &'static str {
92 match level {
93 Strictness::Sketch => "sketch",
94 Strictness::Development => "development",
95 Strictness::Production => "production",
96 }
97}