Skip to content

Commit 98e4062

Browse files
committed
Fix autocfg probing under -D warnings
1 parent 0b5f642 commit 98e4062

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

build.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ fn main() {
2020
let ac = autocfg::new();
2121
let is_nightly = version_meta().unwrap().channel == Channel::Nightly;
2222

23+
// `ac.probe_raw` calls need to be very careful here: under certain configurations, like
24+
// `cargo clippy -- -D warnings`, warnigns in the tested snippets can cause probing to give
25+
// false negatives. It's important to make sure that, for example, there's no unused items or
26+
// variables. See https://github.com/cuviper/autocfg/issues/41.
27+
2328
println!("cargo::rerun-if-env-changed=LITHIUM_THREAD_LOCAL");
2429
if let Ok(thread_local) = std::env::var("LITHIUM_THREAD_LOCAL") {
2530
println!("cargo::rustc-cfg=thread_local=\"{thread_local}\"");
@@ -31,7 +36,7 @@ fn main() {
3136
#![no_std]
3237
extern crate std;
3338
std::thread_local! {
34-
static FOO: () = ();
39+
static FOO: () = const {};
3540
}
3641
",
3742
)
@@ -59,7 +64,7 @@ fn main() {
5964
r"
6065
#![no_std]
6166
extern crate std;
62-
use std::panic::{catch_unwind, resume_unwind};
67+
pub use std::panic::{catch_unwind, resume_unwind};
6368
",
6469
)
6570
.is_ok()
@@ -75,7 +80,7 @@ fn main() {
7580
#![no_std]
7681
extern crate std;
7782
use std::io::Write;
78-
fn main() {
83+
pub fn main() {
7984
let _ = std::io::stderr().write_all(b"hello");
8085
std::process::abort();
8186
}

0 commit comments

Comments
 (0)