Skip to content

chore(dsm): Add separator before type suffix in integer literals.#9432

Merged
daniel-wong-dfinity-org merged 3 commits intomasterfrom
separate-integer-literal-type-suffixes-team-dsm
Mar 18, 2026
Merged

chore(dsm): Add separator before type suffix in integer literals.#9432
daniel-wong-dfinity-org merged 3 commits intomasterfrom
separate-integer-literal-type-suffixes-team-dsm

Conversation

@daniel-wong-dfinity-org
Copy link
Contributor

@daniel-wong-dfinity-org daniel-wong-dfinity-org commented Mar 17, 2026

E.g. 42u64 is changed to 42_u64.

Why: Spaces good.

Why (long version): ThereisareasonthatspaceswereinventedinthefirstplacewhywedonotsimplywriteentireprogramsononelineItisbecausewhenshitiswrittenthiswayitisprofoundlyunreadabledespitetakingupmuchlessspaceSpacesarenotsomeextravaganceTheyareinfactvitaltogoodhumancomprehensionAndthatisalwaysourgoaltooptimizeFORTHEREADERYouarewelcomeforthemigrainethatthisstatementisinducingLetitbeavaluablelessontoyouaboutthenonextravagenceofspacesNowgoforthandusespacejudiciouslyorelsetherobotswillcomeknockingatyourdoorverysoon

Fix stats: ~370 literals, 68 files

How to re-create these changes:

  1. Build the tool. It is not in master yet; rather, it is in review in PR 9418. Until that happens, you'll first need to check out add-integer-type-suffix-separator-tool-daniel-wong. Then, bazel build //rs/tools/add-integer-type-suffix-separator.
  1. Then, check out the master commit that this is based on (originally, 40ad82dbd8) and run the tool against all directories owned by Deterministic State Machine team.
for DIRECTORY in \
    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 \
    rs/crypto/tree_hash \
    rs/query_stats \
    rs/tests/query_stats
do
    ./bazel-bin/rs/tools/add-integer-type-suffix-separator/add-integer-type-suffix-separator $DIRECTORY
done

…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
@github-actions github-actions bot added the chore label Mar 17, 2026
@daniel-wong-dfinity-org daniel-wong-dfinity-org changed the title chore: Add separator before type suffix in integer literals in team-d… chore(dsm): Add separator before type suffix in integer literals. Mar 17, 2026
…/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
@daniel-wong-dfinity-org daniel-wong-dfinity-org marked this pull request as ready for review March 17, 2026 18:43
@daniel-wong-dfinity-org daniel-wong-dfinity-org requested review from a team as code owners March 17, 2026 18:43
Copy link
Contributor

@alin-at-dfinity alin-at-dfinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you.

Copy link
Contributor

@fspreiss fspreiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says what is done and how it is done, but it doesn't say why it is done.

@fspreiss
Copy link
Contributor

@daniel-wong-dfinity-org
Copy link
Contributor Author

Why

Updated. I thought the rationale goes without saying.

unseparated_literal_suffix

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.

@daniel-wong-dfinity-org daniel-wong-dfinity-org added this pull request to the merge queue Mar 18, 2026
Merged via the queue into master with commit 46ea9fc Mar 18, 2026
68 of 69 checks passed
@daniel-wong-dfinity-org daniel-wong-dfinity-org deleted the separate-integer-literal-type-suffixes-team-dsm branch March 18, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants