Open and answer this issue on GitHub.
ready, yaml · opened 2026-11-21 · updated 2026-11-29 · 0 comments
Part of #743 After #743
Decided 2026-11-29 (supervisor): ADR-text-positions-v1 D9 (2276d831), which consolidates ADR-374 (ADR-decision-records-v2 D4).
ADR-text-positions-v1 D8 says a cut at proven positions is not checked at run time. Today every before/after/between/split_at keeps Rust’s boundary check (run reports of 71a74e37 and 6bbfac8b), because nothing ruled out that the text changed while a position of it lived.
Probes on develop 00ccf2cc, nikaia run:
fn main() throws {
let mut t = "ab;cd"
let m = t.find(";") ?? return
t.push_str("ä")
println(t.after(m.end))
}
error[NK1343]: Internal compiler error, rustc cannot borrow t as mutable because it is also borrowed as immutable. Expected NK2305 at the push_str.
fn main() throws {
let mut t = "ab;cd"
let m = t.find(";") ?? return
t = "ä"
println(t.after(m.end))
}
Run-time panic in crates/nikaia-std/src/text_pos.rs:58 (start byte index 3 is out of bounds for string of length 2), with Rust’s message. Expected NK1214 at the cut.
For comparison, the same change under a view is refused as Part I 6.6 says: let v = t.after(t.start()) then t.push_str("x") then println(v) gives NK2305 (t is changed here, but v may point into its data and is used later).
ADR-text-positions-v1 D9: while a position is used, its text stays as it was. A position carries its text’s sources as a view does (D5), so Part I 6.6’s rule for a view holds for it unchanged:
keep or mut parameter, or moving it into a place that must own its text, while a position of it is still used, is NK2305 at the change.NK1214 (D5).So every cut the compiler accepts is at positions of an unchanged text, and D8 drops the boundary check everywhere. Option (b), dropping the check only where the compiler sees no change, is rejected in D9: it keeps a check at every cut the compiler cannot see through.
NK2305 (the rule that refuses the view probe above), so the first probe is NK2305 at the push_str.t = …, a position taken before it is a position of the old text, so the second probe is NK1214 at the cut.is_char_boundary check (D8).tests/compiler/tests/: both probes with their .stderr, and a cut whose lowering has no boundary check.lower-std and build once.The first probe gives NK2305 and the second NK1214, a cut at proven positions lowers without is_char_boundary, each shown by its test, and the commit carries Fixes #2523.
Generated by Claude Code