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