Skip to content

refactor: Stop remove_redundant_let_types from changing types - #2053

Open
thedataking wants to merge 1 commit into
issue-2037from
remove-redundant-let-types
Open

thedataking wants to merge 1 commit into
issue-2037from
remove-redundant-let-types

Conversation

@thedataking

@thedataking thedataking commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

remove_redundant_let_types now removes a let annotation only when the initializer determines the same type without it, so it no longer turns let x: u64 = 0; into an i32 or let p: *mut Foo = &mut s; into a reference.

Split out of #2038 (see this comment).

@thedataking
thedataking force-pushed the remove-redundant-let-types branch from 2e7c537 to 6c46d41 Compare November 5, 2026 12:44
@thedataking thedataking changed the title refactor: Fix type changes in remove_redundant_let_types refactor: Stop remove_redundant_let_types from changing types Nov 5, 2026
@thedataking
thedataking requested a review from ahomescu November 5, 2026 12:44
@thedataking
thedataking marked this pull request as ready for review November 5, 2026 12:44
@thedataking
thedataking force-pushed the remove-redundant-let-types branch from 6c46d41 to a3b6cff Compare November 5, 2026 14:16
@thedataking
thedataking changed the base branch from master to issue-2037 November 5, 2026 14:16
thedataking added a commit to GaloisInc/Tractor-Crisp that referenced this pull request Nov 5, 2026
@thedataking
thedataking added this pull request to stack #2057 November 5, 2026 16:58
`remove_redundant_let_types` compared the annotation with the
initializer's inferred type, but that type already reflects the
annotation, so `let x: u64 = 0;` became an `i32` and
`let p: *mut Foo = &mut s;` became a reference.

Only remove an annotation when the initializer determines its type
without it and isn't coerced: suffixed literals, casts, literals of
non-generic structs, unions and variants, calls to non-generic
functions and methods, operators on such operands, tuples and arrays
of them, field accesses and dereferences of them, and paths to
constants, statics, parameters, and locals whose own types are fixed.
@thedataking
thedataking force-pushed the remove-redundant-let-types branch from a3b6cff to 622a90f Compare November 5, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant