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
//! `not_error` assertion rendering, split out of `swift/assertions.rs` (already over the
//! repo's 1,000-line cap — see `file-modularization` in CLAUDE.md) so this fix's regression
//! coverage has somewhere to live without growing either oversized file. ~keep
use Write as FmtWrite;
/// Render the `not_error` assertion.
///
/// ~keep An uncaught exception already fails the test via `try` propagation, so this function's
/// only job is deciding whether a *further* `XCTAssertNotNil` would add anything. It never can:
/// every non-void call this renders for returns a Swift value declared NON-optional (`func
/// extract(...) async throws -> ExtractionResult`, `func listOcrBackends() throws -> [String]`,
/// the drained `chunks` array, ...), and Swift auto-promotes a non-optional to `Optional` at an
/// `XCTAssertNotNil` call site, so the assertion compiles and can never fail regardless of what
/// the call returned. An audit found this emitted at 40 sites across 15 generated Swift test
/// files, all tautological, and four of them (`testChunkingConfigAndOutput`,
/// `testChunkingRagHandoff`, `testLanguageDetectionConfig`, `testLanguageDetectionMultilingual`
/// in the swift e2e suite) had it as their ONLY assertion once every other assertion on the same
/// fixture was dropped as a `CountOnJsonBridgedLeafInSwift` skip — a document with zero chunks or
/// zero detected languages passed those tests, which is exactly the regression two of them exist
/// to catch.
///
/// - `returns_void` calls bind no `result` at all (see `test_method.rs`'s `if
/// call_config.returns_void` branch), so there's nothing to assert *on* the way the non-void
/// case below does. `test_method.rs` never even reaches this function for that case — its
/// assertion loop skips `not_error` on a void call outright and instead wraps the call itself
/// in `XCTAssertNoThrow` (sync) or a do/catch (async), via its `void_not_error` flag, so the
/// real check lives one level up from here. This branch stays as this function's own correct
/// behavior in isolation — asserting on an unbound variable would not compile — not because the
/// void case goes unchecked. ~keep
/// - Every other case (a bound `result`, the drained `chunks` array, or a bare `Optional<T>`
/// result that may legitimately be `nil` on success) renders the same comment: there is no
/// value it can bind that both compiles and can fail, so `not_error`'s entire contribution is
/// the `try` above it. Collapsing all three to one wording — rather than three call sites that
/// happen to agree — is what keeps a future fourth case from reinventing the tautology.
pub