Skip to content

feat: Tool that changes 42u64 to 42_u64.#9418

Open
daniel-wong-dfinity-org wants to merge 3 commits intomasterfrom
add-integer-type-suffix-separator-tool-daniel-wong
Open

feat: Tool that changes 42u64 to 42_u64.#9418
daniel-wong-dfinity-org wants to merge 3 commits intomasterfrom
add-integer-type-suffix-separator-tool-daniel-wong

Conversation

@daniel-wong-dfinity-org
Copy link
Contributor

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

I will

  1. Run this on code owned by each team.
  2. Create PRs from those fixes. For example, chore(governance): Add separator before type suffix in integer literals. #9412. See that PR for an example of what changes this tool makes.
  3. Once all those changes are in, I will enforce this superior way of writing Rust by adding a GitHub workflow.

Co-written with Claude.

…ach team, create PRs from those fixes, then, once all those changes are in, I will enforce this superior way of writing Rust by adding a GitHub workflow.
@daniel-wong-dfinity-org daniel-wong-dfinity-org force-pushed the add-integer-type-suffix-separator-tool-daniel-wong branch from 3d7bd1b to fa7e0f7 Compare March 17, 2026 10:36
Copy link
Collaborator

@basvandijk basvandijk left a comment

Choose a reason for hiding this comment

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

It's indeed more readable to separate the type suffix with an underscore from the number.

But why not do this via the built-in unseparated_literal_suffix clippy lint by adding
-W clippy::unseparated_literal_suffix to ci/scripts/rust-lint.sh and bazel/conf/.bazelrc.build?

It also supports autofixing like:

cargo clippy --fix -- -W clippy::unseparated_literal_suffix

which we could invoke in our autofix job.

github-merge-queue bot pushed a commit that referenced this pull request Mar 17, 2026
…9434)

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

Fix stats: ~31 literals across 12 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`.

[PR 9418]: #9418

2. Then, check out the master commit that this is based on (originally,
`40ad82dbd8`) and run the tool against all directories owned by the Node
team.

```
for DIRECTORY in \
    rs/boundary_node \
    rs/ic_os \
    rs/tests/boundary_nodes \
    rs/tests/nested \
    rs/tests/node
do
    ./bazel-bin/rs/tools/add-integer-type-suffix-separator/add-integer-type-suffix-separator $DIRECTORY
done

git restore \
  rs/ic_os/networking/nss_icos \
  rs/ic_os/metrics/fstrim_tool \
  rs/tests/nested/nns_recovery
```
github-merge-queue bot pushed a commit that referenced this pull request Mar 18, 2026
…ls. (#9412)

E.g. change `42u64` to `42_u64`. This improves readability by clearly
separating the number from its type suffix.

Fixed 168 numeric literals across 53 files.

Changes were made by running

```
for DIRECTORY in rs/nns rs/sns rs/nervous_system rs/registry
do
    cargo run -p add-integer-type-suffix-separator -- $DIRECTORY
done
```

The tool is not yet in `master` branch; rather, it can be found in draft
#9418, which will be sent out for review "very soon".

Co-Authored with: Claude
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.

2 participants