Skip to content

Commit

Permalink
fix(build-rs)!: Remove meaningless 'cargo_cfg_debug_assertions' (#14901)
Browse files Browse the repository at this point in the history
### What does this PR try to resolve?

The documentation that was added was pulled straight from a comment in
`custom_build.rs`:

> This cfg is always true and misleading, so avoid setting it.
> That is because Cargo queries rustc without any profile settings.

It is therefore misleading to expose this in the API

### How should we test and review this PR?

### Additional information
  • Loading branch information
ehuss authored Dec 6, 2024
2 parents a4a3651 + 71f68dc commit 2560340
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ anstyle = "1.0.8"
anyhow = "1.0.86"
base64 = "0.22.1"
blake3 = "1.5.2"
build-rs = { version = "0.2.0", path = "crates/build-rs" }
build-rs = { version = "0.3.0", path = "crates/build-rs" }
bytesize = "1.3"
cargo = { path = "" }
cargo-credential = { version = "0.4.2", path = "credential/cargo-credential" }
Expand Down
1 change: 0 additions & 1 deletion crates/build-rs-test-lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ fn smoke_test_inputs() {
use build_rs::input::*;
dbg!(cargo());
dbg!(cargo_cfg("careful"));
dbg!(cargo_cfg_debug_assertions());
#[cfg(feature = "unstable")]
dbg!(cargo_cfg_fmt_debug());
#[cfg(feature = "unstable")]
Expand Down
2 changes: 1 addition & 1 deletion crates/build-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "build-rs"
version = "0.2.0"
version = "0.3.0"
rust-version.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
5 changes: 5 additions & 0 deletions crates/build-rs/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ mod cfg {
}

/// If we are compiling with debug assertions enabled.
///
/// Build scripts are not passed this cfg because
/// this cfg is always true and misleading.
/// That is because Cargo queries rustc without any profile settings.
#[cfg(any())]
#[track_caller]
pub fn cargo_cfg_debug_assertions() -> bool {
is_present("CARGO_CFG_DEBUG_ASSERTIONS")
Expand Down

0 comments on commit 2560340

Please sign in to comment.