chore(dsm): Add separator before type suffix in integer literals.#9432
Conversation
…sm-owned code Changes 42u64 -> 42_u64, 42i32 -> 42_i32, etc. The tool was run on the following directories: rs/canister_sandbox rs/canonical_state rs/cycles_account_manager rs/determinism_test rs/embedders rs/execution_environment rs/memory_tracker rs/messaging rs/migration_canister rs/pocket_ic_server rs/query_stats rs/replica_tests rs/replicated_state rs/rust_canisters/backtrace_canister rs/rust_canisters/call_loop_canister rs/rust_canisters/call_tree_test rs/rust_canisters/canister_creator rs/rust_canisters/load_simulator rs/rust_canisters/memory_test rs/rust_canisters/messaging_test rs/rust_canisters/response_payload_test rs/rust_canisters/stable_memory_integrity rs/rust_canisters/stable_structures rs/rust_canisters/statesync_test rs/rust_canisters/xnet_test rs/state_layout rs/state_machine_tests rs/state_manager rs/state_tool rs/sys rs/test_utilities/embedders rs/test_utilities/execution_environment rs/test_utilities/state rs/tests/execution rs/tests/message_routing rs/tree_deserializer rs/types/management_canister_types rs/types/wasm_types rs/universal_canister rs/utils/lru_cache rs/utils/thread rs/xnet
…/override dirs for team-dsm
Changes 42u64 -> 42_u64, 42i32 -> 42_i32, etc.
The tool was run on the following directories:
rs/crypto/tree_hash
rs/query_stats
rs/tests/query_stats
alin-at-dfinity
left a comment
There was a problem hiding this comment.
LGTM, thank you.
fspreiss
left a comment
There was a problem hiding this comment.
The PR description says what is done and how it is done, but it doesn't say why it is done.
|
@daniel-wong-dfinity-org, how about using a clippy lint instead? https://rust-lang.github.io/rust-clippy/master/?search=unsepa#unseparated_literal_suffix |
Updated. I thought the rationale goes without saying.
Before we can enforce that 42u64 is disallowed, we have to make existing code compliant. This is part of that. But yes, unseparated_literal_suffix is the right way to enforce. We just cannot start enforcing yet, because we have (lots of) non-compliant code. Enforcement will be turned on (by PR 9452) in the near future, once all non-compliant code is fixed. |
E.g.
42u64is changed to42_u64.Why: Spaces good.
Why (long version): ThereisareasonthatspaceswereinventedinthefirstplacewhywedonotsimplywriteentireprogramsononelineItisbecausewhenshitiswrittenthiswayitisprofoundlyunreadabledespitetakingupmuchlessspaceSpacesarenotsomeextravaganceTheyareinfactvitaltogoodhumancomprehensionAndthatisalwaysourgoaltooptimizeFORTHEREADERYouarewelcomeforthemigrainethatthisstatementisinducingLetitbeavaluablelessontoyouaboutthenonextravagenceofspacesNowgoforthandusespacejudiciouslyorelsetherobotswillcomeknockingatyourdoorverysoon
Fix stats: ~370 literals, 68 files
How to re-create these changes:
add-integer-type-suffix-separator-tool-daniel-wong. Then,bazel build //rs/tools/add-integer-type-suffix-separator.40ad82dbd8) and run the tool against all directories owned by Deterministic State Machine team.