From 63de601192fa75f3cefdd209586a993eda1845f2 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 14:48:28 +0100 Subject: [PATCH 01/11] edits --- .github/workflows/format.yml | 46 +++++++---------------------------- CMakeLists.txt | 2 +- cpp2rust/converter/mapper.cpp | 3 +-- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 4ef33ade..d0c10758 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -25,43 +25,15 @@ jobs: with: llvm-version: 22 - - name: Setup Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: 1.95.0 - components: rustfmt, clippy - - - name: Setup nightly Rust for rule-preprocessor clippy - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly - components: rustfmt, clippy, rustc-dev + - name: Setup Python + run: pip install ruff - - name: Check C++ formatting - run: find cpp2rust tests -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format --dry-run --Werror + - name: Configure + run: cmake -GNinja -B build -S . - - name: Check Rust formatting - run: | - cargo fmt --manifest-path rules/Cargo.toml -- --check - cargo fmt --manifest-path rule-preprocessor/Cargo.toml -- --check - cargo fmt --manifest-path libcc2rs/Cargo.toml -- --check - cargo fmt --manifest-path libcc2rs-macros/Cargo.toml -- --check - find tests -name '*.rs' -print0 | xargs -0 rustfmt --check + - name: Format files + run: ninja format + working-directory: build - - name: Check Rust lints - run: | - cargo clippy --manifest-path rules/Cargo.toml --all-targets --all-features -- -Dwarnings - cargo +nightly clippy --manifest-path rule-preprocessor/Cargo.toml --all-targets --all-features -- -Dwarnings - cargo clippy --manifest-path libcc2rs/Cargo.toml --all-targets --all-features -- -Dwarnings - cargo clippy --manifest-path libcc2rs-macros/Cargo.toml --all-targets --all-features -- -Dwarnings - - - name: Check Python (ruff) - uses: astral-sh/ruff-action@v3 - with: - args: 'check' - src: tests/lit/lit/formats/Cpp2RustTest.py - - name: Check Python formatting (ruff) - uses: astral-sh/ruff-action@v3 - with: - args: 'format --check' - src: tests/lit/lit/formats/Cpp2RustTest.py + - name: Check format + run: git diff --exit-code diff --git a/CMakeLists.txt b/CMakeLists.txt index e16dda8d..d6547679 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ set(PYTHON_SOURCES ${PROJECT_SOURCE_DIR}/tests/lit/lit/formats/Cpp2RustTest.py) add_custom_target("format" COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES} COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml - COMMAND cargo +${RUST_STABLE_VERSION} --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml + COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features diff --git a/cpp2rust/converter/mapper.cpp b/cpp2rust/converter/mapper.cpp index a0c5ae8c..64b2b7b9 100644 --- a/cpp2rust/converter/mapper.cpp +++ b/cpp2rust/converter/mapper.cpp @@ -564,8 +564,7 @@ std::string normalizeTranslationRule(std::string rule) { static std::string synthesizeAnonRecordName(const clang::RecordDecl *record) { std::string parent_name; - if (auto *parent = - clang::dyn_cast(record->getDeclContext())) { + if (auto *parent = clang::dyn_cast(record->getDeclContext())) { parent_name = parent->getIdentifier() ? parent->getIdentifier()->getName().str() : synthesizeAnonRecordName(parent); From f77cc90290ab4464928a88e0714a3e70f8c22e7d Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 14:52:35 +0100 Subject: [PATCH 02/11] edits --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6547679..b46fb526 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") add_custom_command( OUTPUT "${RUST_STAMP_FILE}" - COMMAND rustup toolchain install ${RUST_STABLE_VERSION} + COMMAND rustup toolchain install ${RUST_STABLE_VERSION} --component clippy --component rustfmt COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake" From 59ff7f14f36d9cdd5a1aef7d1558337784cb5323 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 14:56:01 +0100 Subject: [PATCH 03/11] edits --- .github/workflows/format.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index d0c10758..0aea664d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -19,6 +19,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v6 + with: + fetch-depth: 1 - name: Setup LLVM uses: ZhongRuoyu/setup-llvm@v0 From 8d44b82d87496c6cdcd6b28948fa15ede6db78a3 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 14:59:55 +0100 Subject: [PATCH 04/11] edits --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 0aea664d..f22dc191 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -20,7 +20,7 @@ jobs: - name: Checkout code uses: actions/checkout@v6 with: - fetch-depth: 1 + fetch-depth: 2 - name: Setup LLVM uses: ZhongRuoyu/setup-llvm@v0 From c4d62d129fac9a7c7551ed75dce52b6d69e007d2 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 15:19:30 +0100 Subject: [PATCH 05/11] edits --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index f22dc191..7816845c 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -20,7 +20,7 @@ jobs: - name: Checkout code uses: actions/checkout@v6 with: - fetch-depth: 2 + fetch-depth: 0 - name: Setup LLVM uses: ZhongRuoyu/setup-llvm@v0 From 8dd5e4bbf1eaf8748688d7a7cd1956d37fdb729f Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 15:34:00 +0100 Subject: [PATCH 06/11] edits --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b46fb526..caf21db9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,13 +94,13 @@ add_custom_target("format" COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml -- -Dwarnings - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path $${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml -- -Dwarnings COMMAND ${RUFF} --silent check --fix ${PYTHON_SOURCES} COMMAND ${RUFF} --silent format ${PYTHON_SOURCES} From ee269fe0f19a176ed543b8be131b0abdde1fbf47 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 15:40:31 +0100 Subject: [PATCH 07/11] edits --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index caf21db9..456315e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,9 @@ add_custom_target("format" COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml -- -Dwarnings COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features - --manifest-path chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings + --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features - --manifest-path $${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings + --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml -- -Dwarnings COMMAND ${RUFF} --silent check --fix ${PYTHON_SOURCES} From 650857d43f064bfefd92c61a4484846384b0d76d Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 15:58:13 +0100 Subject: [PATCH 08/11] edits --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 456315e7..b235cabd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,12 +91,12 @@ set(PYTHON_SOURCES ${PROJECT_SOURCE_DIR}/tests/lit/lit/formats/Cpp2RustTest.py) add_custom_target("format" COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES} COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml - COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml + COMMAND cargo +${RUST_NIGHTLY_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml -- -Dwarnings - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features + COMMAND cargo +${RUST_NIGHTLY_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings From 353925250028a24f4b84c709cb6bb7224d28b5af Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 16:08:00 +0100 Subject: [PATCH 09/11] edits --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b235cabd..accae667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") add_custom_command( OUTPUT "${RUST_STAMP_FILE}" COMMAND rustup toolchain install ${RUST_STABLE_VERSION} --component clippy --component rustfmt - COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools + COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools --component clippy --component rustfmt COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake" USES_TERMINAL From 59e2f8d809a80034e8cb2cb1c783f5efc7e6759b Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 16:12:51 +0100 Subject: [PATCH 10/11] edits --- cpp2rust/converter/mapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp2rust/converter/mapper.cpp b/cpp2rust/converter/mapper.cpp index 64b2b7b9..a0c5ae8c 100644 --- a/cpp2rust/converter/mapper.cpp +++ b/cpp2rust/converter/mapper.cpp @@ -564,7 +564,8 @@ std::string normalizeTranslationRule(std::string rule) { static std::string synthesizeAnonRecordName(const clang::RecordDecl *record) { std::string parent_name; - if (auto *parent = clang::dyn_cast(record->getDeclContext())) { + if (auto *parent = + clang::dyn_cast(record->getDeclContext())) { parent_name = parent->getIdentifier() ? parent->getIdentifier()->getName().str() : synthesizeAnonRecordName(parent); From 3854e5cff8e4458cddd0d10c22f17a5000dac489 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 16:29:48 +0100 Subject: [PATCH 11/11] edits --- .github/workflows/format.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 7816845c..d0c10758 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -19,8 +19,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v6 - with: - fetch-depth: 0 - name: Setup LLVM uses: ZhongRuoyu/setup-llvm@v0