Skip to content

Commit

Permalink
Auto merge of #7970 - ehuss:revert-debug-assert-filter, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Mar 5, 2020
2 parents 5fe8ab5 + b8ab32e commit 9443875
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ impl TargetInfo {

fn not_user_specific_cfg(cfg: &CargoResult<Cfg>) -> bool {
if let Ok(Cfg::Name(cfg_name)) = cfg {
if cfg_name == "debug_assertions" || cfg_name == "proc_macro" {
// This should also include "debug_assertions", but it causes
// regressions. Maybe some day in the distant future it can be
// added (and possibly change the warning to an error).
if cfg_name == "proc_macro" {
return false;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
}
}
for (k, v) in cfg_map {
if k == "debug_assertions" {
// This cfg is always true and misleading, so avoid setting it.
// That is because Cargo queries rustc without any profile settings.
continue;
}
let k = format!("CARGO_CFG_{}", super::envify(&k));
match v {
Some(list) => {
Expand Down

0 comments on commit 9443875

Please sign in to comment.