1mod bounded;
8mod codes;
9mod diagnostic;
10mod error;
11mod module;
12pub(crate) mod nonfinite;
13mod output;
14mod records;
15mod scenario;
16mod source;
17mod time_series;
18mod validation;
19
20pub use codes::CORE_DIAGNOSTIC_CODES;
21pub use diagnostic::{
22 CodeStatus, Diagnostic, DiagnosticCode, DiagnosticInfo, DiagnosticSeverity, DiagnosticStage,
23 ErrorCategory, check_registry, check_scope_ownership, code_is_well_formed, render_diagnostic,
24 render_diagnostics,
25};
26pub use error::Error;
27pub use module::PioModule;
28pub use output::{ArtifactPath, Destination, MemoryArtifact, WriteResult, WrittenOutput};
29pub use records::{
30 DiagnosticId, Digest, DigestAlgorithm, HistoryEntry, HistoryId, HistoryKind, Producer,
31 SourceDescriptor, SourceId, SourceMapEntry, SourceRelation, SourceSpan,
32};
33pub use scenario::{SCENARIO_PROBABILITY_TOLERANCE, Scenario, ScenarioId, ScenarioSet};
34pub use source::{FormatId, Source, SourceBuffer};
35pub use time_series::{TimePoint, TimeSeries};
36
37pub mod limits {
45 pub use crate::bounded::{BoundedStr, TruncatedStr, bounded_json_map, bounded_vec};
46 pub use crate::validation::{
47 MAX_DIAGNOSTIC_CODE_BYTES, MAX_DIAGNOSTIC_DETAIL_KEYS, MAX_DIAGNOSTIC_MESSAGE_BYTES,
48 MAX_DIAGNOSTIC_MESSAGE_DECODE_BYTES, MAX_DIAGNOSTIC_RELATED, MAX_DIAGNOSTIC_SPANS,
49 MAX_DIAGNOSTIC_TARGET_BYTES, MAX_HISTORY_NOTES, MAX_HISTORY_PARAMETERS,
50 MAX_IDENTIFIER_BYTES, MAX_MODULE_DIAGNOSTICS, MAX_MODULE_EXTENSION_KEYS,
51 MAX_MODULE_HISTORY_ENTRIES, MAX_MODULE_SOURCE_MAP_ENTRIES, MAX_MODULE_SOURCES,
52 MAX_SOURCE_MAP_SPANS,
53 };
54}
55
56#[doc(hidden)]
72pub mod __implementation {
73 pub mod nonfinite {
75 pub use crate::nonfinite::*;
76 }
77
78 pub use crate::output::__commit_staged_file;
81}
82
83#[macro_export]
88macro_rules! diagnostic_codes {
89 ($(
90 $(#[$attr:meta])*
91 $name:ident = $code:literal, $severity:ident, $summary:literal
92 $(, category = $category:ident)?
93 $(, retired = $since:literal)? ;
94 )*) => {
95 $(
96 $(#[$attr])*
97 pub const $name: $crate::DiagnosticInfo = $crate::DiagnosticInfo::new(
98 $code,
99 $crate::DiagnosticSeverity::$severity,
100 $summary,
101 )
102 $(.with_category($crate::ErrorCategory::$category))?
103 $(.retired($since))?;
104 )*
105
106 pub const ALL: &[&$crate::DiagnosticInfo] = &[$(&$name),*];
108 };
109}
110
111#[cfg(test)]
112mod tests {
113 #[test]
121 fn hidden_root_items_match_the_implementation_module_note() {
122 let source = include_str!("lib.rs");
123
124 let top_level_hidden = source
125 .lines()
126 .filter(|line| line.trim() == "#[doc(hidden)]")
127 .count();
128 assert_eq!(
129 top_level_hidden, 1,
130 "exactly one #[doc(hidden)] item is expected at the crate root: __implementation"
131 );
132
133 let start = source
134 .find("pub mod __implementation {")
135 .expect("the __implementation module must exist");
136 let mut depth = 0i64;
137 let mut direct_items = Vec::new();
138 for (index, line) in source[start..].lines().enumerate() {
139 if index == 0 {
140 depth += i64::try_from(line.matches('{').count()).unwrap();
141 depth -= i64::try_from(line.matches('}').count()).unwrap();
142 continue;
143 }
144 if depth == 1 {
145 let trimmed = line.trim();
146 if trimmed.starts_with("pub mod ") || trimmed.starts_with("pub use ") {
147 direct_items.push(trimmed.to_owned());
148 }
149 }
150 depth += i64::try_from(line.matches('{').count()).unwrap();
151 depth -= i64::try_from(line.matches('}').count()).unwrap();
152 if depth <= 0 {
153 break;
154 }
155 }
156
157 assert_eq!(
158 direct_items,
159 vec![
160 "pub mod nonfinite {".to_owned(),
161 "pub use crate::output::__commit_staged_file;".to_owned(),
162 ],
163 "__implementation's direct items no longer match the audit note above it"
164 );
165 }
166}