Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in nightly handling features + debug assertions #7966

Closed
richardwhiuk opened this issue Mar 4, 2020 · 1 comment · Fixed by #7970
Closed

Regression in nightly handling features + debug assertions #7966

richardwhiuk opened this issue Mar 4, 2020 · 1 comment · Fixed by #7970
Labels
C-bug Category: bug

Comments

@richardwhiuk
Copy link

Problem

1.43.0-nightly (4ad624882 2020-03-03) has regressed handling of debug assertions with features.

Steps

  1. Install 1.43.0-nightly (4ad624882 2020-03-03)

  2. Build a crate with the following Cargo.toml

[package]
name = "test-bin"
version = "0.1.0"
edition = "2018"

[dependencies]
rocket_contrib = { version = "0.4.2", features = [ "templates", "tera_templates" ] }
  1. Build fails with:
   Compiling rocket_contrib v0.4.3
error[E0463]: can't find crate for `notify`
  --> /opt/rust/registry/src/crates-io-27bb2a0041c1489d/rocket_contrib-0.4.3/src/templates/fairing.rs:35:5
   |
35 |     extern crate notify;
   |     ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `rocket_contrib`.

To learn more, run the command again with --verbose.

Cargo has not downloaded the required crate, so I assume a Cargo bug, instead of a rustc bug.

  1. Build works with cargo 1.43.0-nightly (e57bd0299 2020-02-21)

Possible Solution(s)

Dependency is pulled in via a debug assertion:

https://github.com/SergioBenitez/Rocket/blob/v0.4.2/contrib/lib/Cargo.toml#L79-L80

notify is not downloaded by Cargo during a clean build.

Cargo.lock does reference notify:

[[package]]
name = "rocket_contrib"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66926894ef94396204c53885f54a1b0e94a88ce6c9478c2fd403261fc0efb523"
dependencies = [
 "glob 0.3.0",
 "log 0.4.8",
 "notify",
 "rocket",
 "serde",
 "serde_json",
 "tera",
]

This is a recent regression - rust version 1.43.0-nightly (d3c79346a 2020-02-29) also works.

Suspect #7962 is at fault,.

@richardwhiuk richardwhiuk added the C-bug Category: bug label Mar 4, 2020
@alexcrichton
Copy link
Member

In general cfg(debug_assertions) can't be used to gate inclusion of crates in dependencies, and a warning was added for that in #7660. This seems likely due to #7820 (cc @ehuss) where we reorganized where this information was calculated.

@bors bors closed this as completed in 9443875 Mar 5, 2020
@bors bors closed this as completed in #7970 Mar 5, 2020
ehuss pushed a commit to ehuss/cargo that referenced this issue Mar 16, 2020
…excrichton

Partially revert change to filter debug_assertions.

This partially reverts the changes from rust-lang#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 rust-lang#7966.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants