Skip to content

Commit 3a4e872

Browse files
committed
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`.)
1 parent 709eaf0 commit 3a4e872

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
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

+1-1
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

0 commit comments

Comments
 (0)