Skip to content

Conversation

@jdonszelmann
Copy link
Contributor

Something like this? It asserts during encoding that for that type, decoding 0 would give the default.
Preferably, I'd either somehow statically/in const assert it once, instead of every time, but I see no easy way to do so. It'd require us to iterate all types that implement the trait or something. Let me know what you think

No types currently violate this invariant.

r? @oli-obk

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 18, 2025

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 18, 2025

Yea, let's wait for a const check for when const traits are sth we feel happy with using inside rustc itself

@oli-obk
Copy link
Contributor

oli-obk commented Nov 18, 2025

@bors r+ rollup

Thanks for doing the work on random things I find <3

@bors
Copy link
Collaborator

bors commented Nov 18, 2025

📌 Commit d1bcf2e has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2025
bors added a commit that referenced this pull request Nov 18, 2025
Rollup of 5 pull requests

Successful merges:

 - #147887 (Improve the documentation of atomic::fence)
 - #148281 (repr(transparent) check: do not compute check_unsuited more than once)
 - #148484 (Fix suggestion for the `cfg!` macro)
 - #149057 (`rust-analyzer` subtree update)
 - #149061 (debug-assert FixedSizeEncoding invariant)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Nov 18, 2025
Rollup of 5 pull requests

Successful merges:

 - #147887 (Improve the documentation of atomic::fence)
 - #148281 (repr(transparent) check: do not compute check_unsuited more than once)
 - #148484 (Fix suggestion for the `cfg!` macro)
 - #149057 (`rust-analyzer` subtree update)
 - #149061 (debug-assert FixedSizeEncoding invariant)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ceb33e9 into rust-lang:main Nov 19, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 19, 2025
rust-timer added a commit that referenced this pull request Nov 19, 2025
Rollup merge of #149061 - jdonszelmann:fixed-size-encoding-assert, r=oli-obk

debug-assert FixedSizeEncoding invariant

Something like this? It asserts during encoding that for that type, decoding 0 would give the default.
Preferably, I'd either somehow statically/in const assert it once, instead of every time, but I see no easy way to do so. It'd require us to iterate all types that implement the trait or something. Let me know what you think

No types currently violate this invariant.

r? `@oli-obk`
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Nov 19, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#147887 (Improve the documentation of atomic::fence)
 - rust-lang/rust#148281 (repr(transparent) check: do not compute check_unsuited more than once)
 - rust-lang/rust#148484 (Fix suggestion for the `cfg!` macro)
 - rust-lang/rust#149057 (`rust-analyzer` subtree update)
 - rust-lang/rust#149061 (debug-assert FixedSizeEncoding invariant)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants