14. Calls made bringing the Rust front end up to the libraries (2026-11-20)
The Rust checker now accepts stdlib/, examples/local-lib/ and
proto/ports/ unchanged. Where the source needed a rule the plan does
not state, these calls were made. None is confirmed by Ryan yet.
-
14.1 A value with more fields fits where fewer are asked for. The library passes a
Group<T>where aMonoid<T>is expected, and a(u, v, w)edge where(u, v)is:struct Monoid<T>(id: T, op: (T, T) -> T) struct Group<T>(id: T, op: (T, T) -> T, inv: T -> T) let sums = SegTree<I, Int>.from(Sum<Int>, a) // Sum<Int> is a Group<Int>The checker accepts a struct for another struct when it has every field the other has, at the same types, and a record for a narrower record. The alternative is a conversion at every such call.
- 14.2 An impl's type parameters are read off its header.
impl Add for Mod<P>does not declareP; a type argument in the header that names nothing in scope is a parameter of the impl.
-
14.3 Top-level statements see the lends and asserts before them. A file's top-level statements are checked one at a time. A slice bound by a top-level
letstill keeps its array lent in the statements after it, and a top-levelassert i != jholds untiliorjis assigned:let part = a[l..=r] a[l] = 0 // error: `a` is lent to `part` until its last use print(part[l])
- 14.4 The prototype's built-in names are accepted without a type.
The ports use
SegTree,Mod,Graph,dijkstraand some twenty more names with nouse, becauseproto/cpcbuilds them in. The checker lists them incrates/cpl-check/src/prelude.rsand does not type what goes through them. This is a stopgap: the fix is for each port tousethestdmodule, at which point the name leaves the list.