Repository navigation
Define the serde bool default once in state.rs - #8
Open
kridaydave wants to merge 1 commit into
Open
kridaydave wants to merge 1 commit into
kridaydave wants to merge 1 commit into
Conversation
default_true was written out three times with identical bodies, in state.rs, fabric.rs and server.rs. A serde default can be a path, so all three now reference the one in state.rs. Net -8 lines. No behavior change: the bodies were byte-identical and the serde attribute resolves the same function.
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.
Problem
fn default_true() -> bool { true }was written out three times with identical bodies:src/state.rs:23,src/fabric.rs:37,src/server.rs:239. It is the serde default behind five fields (Runtime.pinned,Policy.require_signed,Policy.require_check_strict,CheckReq.strict, and one more), so it is policy that already has a canonical home.Change
A
serde(default = "...")attribute accepts a path, sofabric.rsandserver.rsnow point atcrate::state::default_trueand their private copies are deleted.state.rsmakes the one copypub(crate).No behavior change. The three bodies were byte-identical, and the attribute resolves to the same function.
Diff
Verification
cargo fmt --all -- --checkclean,cargo clippy --locked -- -D warningsclean. The test suite is CI's to run.Not shipped
src/registry.rs:82-88andsrc/registry.rs:147-152re-check the hash afterStateEngine::verify, which already does the identical check atsrc/engine.rs:74-80. Dead. Not removed here because it touches the security boundary and deserves its own PR with its own proof.src/registry.rs:273-274is a stale comment describing a lowercase normalization that is not in the code.