Skip to content

Commit 7a0bb7c

Browse files
authored
Fixes to rust-toolchain.toml handling (#1225)
This fixes a few aspects of the `rust-toolchain.toml` handling, to make it easier to make future changes such as limiting the use of `rust-toolchain.toml` to the tools that use rustc internals. Fix a few obsolete references to `rust-toolchain` rather than `rust-toolchain.toml`, since c2rust doesn't use the former. Use the `rustfmt` component rather than `rustfmt-preview`, since the latter is obsolete (rustfmt has not been a "preview" for a long time). Finally, make `c2rust-transpile` use a separate file for the generated `rust-toolchain.toml`. When c2rust-transpile translates C variadics, it generates code using the (currently) nightly-only feature `c_variadics`, so it emits a `rust-toolchain.toml` file to use nightly. Rather than copy this file from the `rust-toolchain.toml` used to build c2rust itself, use a separate file. This also means the generated `rust-toolchain.toml` can stop requiring toolchain components that the generated code doesn't need, such as rustc-dev. (It still requires `rustfmt`, as c2rust may run `cargo fmt` on the generated code if invoking `c2rust-refactor`.)
2 parents 347969a + 3a4e872 commit 7a0bb7c

File tree

6 files changed

+9
-5
lines changed

6 files changed

+9
-5
lines changed

.github/workflows/internal-testsuite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
~/.rustup/toolchains
4040
~/.rustup/update-hashes
4141
~/.rustup/settings.toml
42-
key: ${{ runner.os }}-rust-toolchain-${{ hashFiles('rust-toolchain') }}
42+
key: ${{ runner.os }}-rust-toolchain-${{ hashFiles('**/*rust-toolchain.toml') }}
4343

4444
- name: Cache Rust artifacts
4545
uses: actions/cache@v4

analysis/tests/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.bc
2-
rust-toolchain
2+
# Sometimes generated by c2rust
3+
rust-toolchain.toml
34

45
instrument.out.log
56
instrument.err.jsonl
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "nightly-2022-08-08"
3+
components = ["rustfmt"]

c2rust-transpile/src/build_files/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ fn emit_lib_rs(
260260
/// on a nightly toolchain until the `c_variadics` feature is stable.
261261
fn emit_rust_toolchain(tcfg: &TranspilerConfig, build_dir: &Path) {
262262
let output_path = build_dir.join("rust-toolchain.toml");
263-
let output = include_str!("../../rust-toolchain.toml").to_string();
263+
let output = include_str!("generated-rust-toolchain.toml").to_string();
264264
maybe_write_to_file(&output_path, output, tcfg.overwrite_existing);
265265
}
266266

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
22
channel = "nightly-2022-08-08"
3-
components = ["rustfmt-preview", "rustc-dev", "rust-src", "miri", "rust-analyzer"]
3+
components = ["rustfmt", "rustc-dev", "rust-src", "miri", "rust-analyzer"]

tests/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ c2rust-lib.rs
1919
!build.rs
2020

2121
# sometimes generated by `c2rust`
22-
rust-toolchain
22+
rust-toolchain.toml
2323

2424
# sometimes generated by `c2rust`, but only in `src/`
2525
**/src/Cargo.toml

0 commit comments

Comments
 (0)