Codegen intercepts: fold stem-prefix carve-out into registry (raw-buf.1 follow-up) #36
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
raw-buf.1 (commit
140a0c0) consolidated the legacytry_emit_primitive_instance_bodyarms into a registry table.The companion predicate
intercept_emit_wants_alwaysinlineatcrates/ailang-codegen/src/lib.rs:1172now consults the registryfor branch 1 (the 13-name literal list) — one source of truth.
Branch 2 of that predicate stays hardcoded: a stem-prefix carve-out
matching
{ne|lt|le|gt|ge}__*that returnswants_alwaysinline = truefor polymorphic-body monomorphizations like
lt__Bool,ne__Str,ne__MyADT. These are NOT registry entries (they're generated bythe mono pass, not by a hand-written intercept) and never were.
Their
alwaysinlineattribute matters for the bench-perf parityestablished in iter
operator-routing-eq-ord.1.Two ways to dissolve the carve-out:
Extend
Interceptto support predicate-only entries. Add avariant like
Intercept { name_predicate: fn(&str) -> bool, wants_alwaysinline: bool, ... }or split the type intoNamedIntercept+PredicateIntercept. Register the{ne|lt|le|gt|ge}__*carve-out as a predicate-only entry withno
emit(the dispatch site already handles "registered but nobody" via the existing fallback).
Accept the carve-out as final shape. Branch 2 is short
(~6 lines), well-commented, and the carve-out is a closed set
under the current operator-routing design. Living with two
branches is cheap if no third class is anticipated.
Option 1 is the architecturally complete fold; option 2 is
pragmatic. No urgency — branch 2 is correct as-is. Worth raising
when a third carve-out class shows up, or when raw-buf.3's RawBuf
intercepts surface a similar pattern that wants similar treatment.
Refs #7.
Verification 2026-06-02: Still VALID.
intercept_emit_wants_alwaysinlinenow atcrates/ailang-codegen/src/lib.rs:1247(was 1172). Branch 1 still consults the registry; branch 2's stem-prefix carve-out for{ne|lt|le|gt|ge}__*is unchanged and still hardcoded separate from the registry.