1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
//! The unified diagnostic every stage emits.
//!
//! `architecture.md`'s one-diagnostics-channel contract: "diagnostics carry a
//! `Span`, a stage of origin, and structured parts; all rendering (CLI, LSP,
//! JSON, corpus reports) consumes the same finished `Vec<Diagnostic>`. This
//! structurally removes the two-independent-assembly-paths failure mode in
//! canon."
//!
//! # The verdict rules, as types (P4-6a)
//!
//! `assurance.md`'s "verdicts are proofs" rules are enforced by construction
//! rather than by review:
//!
//! - [`Severity::Error`] is reachable only through [`Diagnostic::proven`],
//! which takes a non-empty [`WitnessChain`] naming fact groups, or through
//! [`Diagnostic::legacy_error`], which takes a declared [`Exemption`]
//! counted by `docs/davinci/plan/witness-exemptions.tsv` — an inventory
//! that only shrinks.
//! - [`Diagnostic::new`] takes an [`Advisory`] severity, so an error without
//! a witness is a type error — the provisional "canary that tries
//! error-on-unknown fails to compile":
//!
//! ```compile_fail,E0308
//! use vize_l0::diag::{Diagnostic, Severity, Stage};
//! use vize_l0::Span;
//!
//! let unproven = Diagnostic::new(Severity::Error, Stage::Semantic, Span::new(0, 1), "maybe");
//! ```
//!
//! Its twin, identical but for the severity, builds — so the canary fails
//! for exactly the severity (stable rustdoc does not check the error code;
//! the twin is what pins the reason):
//!
//! ```
//! use vize_l0::diag::{Advisory, Diagnostic, Stage};
//! use vize_l0::Span;
//!
//! let unproven = Diagnostic::new(Advisory::Warning, Stage::Semantic, Span::new(0, 1), "maybe");
//! ```
//!
//! - The fields that carry the claim — severity and witness — are private,
//! so a struct literal cannot forge an unwitnessed error either:
//!
//! ```compile_fail,E0451
//! use vize_l0::diag::{Diagnostic, Severity, Stage};
//! use vize_l0::Span;
//!
//! let forged = Diagnostic {
//! severity: Severity::Error,
//! stage: Stage::Semantic,
//! span: Span::new(0, 1),
//! message: "maybe".into(),
//! parts: Vec::new(),
//! witness: None,
//! };
//! ```
//!
//! - Rules declare a [`RuleContract`] — a [`Tier`] over a declared
//! [`Domain`] — whose const constructor rejects a heuristic rule declaring
//! error severity at compile time (see [`tier`]).
//!
//! Re-checking a witness against the fact base is P4-6b's verifier
//! (`vize_l0::diag::verify`); this module only makes the unproven error
//! unrepresentable.
//!
//! # Coordinates
//!
//! A diagnostic keys on [`vize_l0::Span`] — two byte offsets — and nothing
//! else. `Position` does not exist: P1-4 retired line/column tracking after
//! measuring the parser's to be degenerate by construction, and P1-3 shrank
//! `SourceLocation` from 48 bytes to 8 by making it span-only. Line and column
//! are **derived at rendering time** from the authored text, via
//! `vize_l0::line_index::LineIndex`.
//!
//! # Ownership: why the text is owned
//!
//! Every field is `'static`, enforced by the assertion at the bottom of this
//! file. That is the P1-11 arena/cache contract: a compile's arena is reset
//! and reused for the next file, so anything crossing a compile boundary must
//! own its bytes or it is reading freed memory. Diagnostics cross that
//! boundary by definition — they outlive the compile that produced them, get
//! collected across a batch, and get cached.
//!
//! Message text is therefore **owned**, the deliberate P1-10 exception that
//! `vize_relief::CompilerError::message` already carries. Every other node
//! field in the compiler moved to `&'a str` in that change; diagnostics did
//! not, for exactly this reason.
use Vec;
pub use crateStage;
pub use MessageLookup;
pub use ;
pub use ;
pub use Verdict;
use ;
pub use ;
/// What a structured part of a diagnostic is doing.
/// One labelled span of a diagnostic.
///
/// Structured parts are what make the rustc/Elm-grade bar (charter #42)
/// reachable by the renderer instead of by string assembly in each producer:
/// a renderer receives spans and roles, never a pre-formatted sentence it has
/// to re-parse.
/// A diagnostic from any stage, in the one channel every renderer reads.
///
/// `severity` and `witness` are private and paired by the constructors: an
/// error always carries a [`Witness`] — a proof or a counted exemption — and
/// nothing can lower that pairing after construction.
/// The classification enums are single-byte tags on every target, so these
/// hold on the wasm32 lane P2-14 makes required as well - see the note on
/// `NodeId`'s asserts for why they are not pointer-width-guarded.
const _: = assert!;
const _: = assert!;
const _: = assert!;
const _: = assert!;
/// `Diagnostic` is one owned value copied into batch collections and caches, so
/// a fat one is paid for per finding: 88 bytes is `Span` (8) + severity/stage
/// tags + an owned `String` message (24) + the parts `Vec` (24) + the witness
/// slot (24). The witness keeps that slot size because its chain is a boxed
/// slice (16) and an exemption is a `&'static` reference (8) — the P2-1 note's
/// "a real witness type must be boxed rather than inlined", honoured. These are
/// 64-bit footprints of pointer-containing structs, so they carry the
/// `vize_relief` guard.
const _: = assert!;
const _: = assert!;
const _: = assert!;
/// Type-level half of the P1-11 arena/cache contract: a diagnostic that
/// borrowed arena bytes could not be `'static`, so this stops compiling if one
/// ever does. Same enforcement the batch cache types carry.
const _: = ;