Skip to content

Commit 9443875

Browse files
committed
Auto merge of #7970 - ehuss:revert-debug-assert-filter, r=alexcrichton
Partially revert change to filter debug_assertions. This partially reverts the changes from #7943. It caused a regression with the rocket_contrib crate. I knew that was the only crate that had a `cfg(debug_assertions)` dependency, and I saw that it had been fixed, but I did not realize the fix hadn't been published (and will be in a semver incompatible release). This retains the old behavior for `cfg(debug_assertions)` of issuing a warning. I kept the filter for `CARGO_CFG_DEBUG_ASSERTIONS` for build scripts because that was the original intent for the change, and I don't see anyone using that. Closes #7966.
2 parents 5fe8ab5 + b8ab32e commit 9443875

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/cargo/core/compiler/build_context/target_info.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ impl TargetInfo {
192192

193193
fn not_user_specific_cfg(cfg: &CargoResult<Cfg>) -> bool {
194194
if let Ok(Cfg::Name(cfg_name)) = cfg {
195-
if cfg_name == "debug_assertions" || cfg_name == "proc_macro" {
195+
// This should also include "debug_assertions", but it causes
196+
// regressions. Maybe some day in the distant future it can be
197+
// added (and possibly change the warning to an error).
198+
if cfg_name == "proc_macro" {
196199
return false;
197200
}
198201
}

src/cargo/core/compiler/custom_build.rs

+5
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
228228
}
229229
}
230230
for (k, v) in cfg_map {
231+
if k == "debug_assertions" {
232+
// This cfg is always true and misleading, so avoid setting it.
233+
// That is because Cargo queries rustc without any profile settings.
234+
continue;
235+
}
231236
let k = format!("CARGO_CFG_{}", super::envify(&k));
232237
match v {
233238
Some(list) => {

0 commit comments

Comments
 (0)