From 3ab02afdafb2a8ff5911ccc30fcc4b4c5b64b204 Mon Sep 17 00:00:00 2001 From: zjp Date: Sat, 16 Mar 2024 15:04:25 +0800 Subject: [PATCH] fix: cfg nighyly for integration test for cargo-dist to work on stable --- tests/integration/build.rs | 8 ++++++++ tests/integration/src/lib.rs | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/integration/build.rs diff --git a/tests/integration/build.rs b/tests/integration/build.rs new file mode 100644 index 0000000..a092445 --- /dev/null +++ b/tests/integration/build.rs @@ -0,0 +1,8 @@ +fn main() -> Result<(), Box> { + let output = std::process::Command::new("rustc").arg("-V").output()?; + // set nightly cfg if current toolchain is nightly + if std::str::from_utf8(&output.stdout)?.contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } + Ok(()) +} diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 36fe616..fab0305 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(c_variadic)] +#![cfg_attr(nightly, feature(c_variadic))] /// Documentation for struct AUnitStruct. pub struct AUnitStruct; @@ -108,8 +108,10 @@ where { } /// # Safety +#[cfg(nightly)] pub unsafe extern "C" fn variadic(_: *const (), _name: ...) {} /// # Safety +#[cfg(nightly)] pub unsafe extern "C" fn variadic_multiline(_: *const (), _: *mut (), _name: ...) {} pub trait ATraitWithGAT {