Repository navigation
with fix-ceremony --report says which narrowing casts of a length a declaration demands and which set a width nothing asks for (#2522) - #3571
Merged
Conversation
…eclaration demands and which set a width nothing asks for (#2522)
This was referenced Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2522 (step one of the plan on the issue). Report only; no source is rewritten.
D183 ruled that most
.len() as i32sites should stop being conversions at all, and that a conversion that remains points at the declaration whose width is wrong, never at the use. To work that list the sites have to be told apart by what the compiler knows, not by their text.Sema now records each narrowing cast of a
len()call in one of two classes, at the place it already records a widening cast under a demand:with fix-ceremony --reportprints one line per cast and a summary. It does not rewrite them: dropping one in place turns a wrap into a range check where it stands, which the ruling names as a cost.On the compiler today: 621 length casts, 260 demanded by a declaration, 361 that set a width nothing asks for.
Also verified while here: the pinned seed accepts D183's checked narrowing (
let n: i32 = xs.len()checks undersrc/main, with the D183 lint), so the compiler's own casts are no longer held back by the seed.Test: a case in
test/internals_compiler/ceremony_fix_test.with(five casts over the two classes, a widening cast that is neither, and no edit touching a narrowing cast).Battery green; self-audit and
:release-checksgreen (605 s).