-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo metadata: Don't show null
deps.
#6534
Conversation
r? @Eh2406 (rust_highfive has picked a reviewer for you, use r? to override) |
b7630d6
to
a2fc5cf
Compare
Field missing vs field set to null.. Hmm, not sure which is best or if there's an established convention in we're using and should continue to follow. |
It's not just the field, it's the entire "deps": [
{
"name": null,
"pkg": "bdep 0.5.0 (path+file:///bdep)"
}
], and "deps": [], This causes things like |
What is |
Oh right, https://github.com/oli-obk/cargo_metadata. So this is resolving an incoherence between cargo and that crate. |
I would love to see us more involved in making sure that cargo and cargo_metadata always work together. What is the use case for depending on a crate without a library? In that use case should cargo_metadata's users have to be aware that that crate exists? |
I can't think of a legitimate case. I scanned all of crates.io for packages with binary dependencies, and all I found were:
The clippy ones are because a special version of clippy was published that says "do not use me". I suspect the cargo-watch thing was just a mistake. |
Oh, and the reason I found this is because I was working on a new test suite for cargo_metadata. 😆 |
Maybe we should depend on cargo_metadata, or maybe we should have a crate inside this repo that cargo_metadata depends on (or is replaced by). (sorry, veering off-topic) |
If the team is on board with having closer ties then we should open up a discussion of how that looks. (I have thoughts, but it is off topic here.) I feel a little uncomfortable removing information from our output. This is a thing a project can do, and metadata is how tooling will find out about it. Like I am not sure the bug is on the cargo side. That being said I don't want to make |
Yeah, I think that's a sound argument. I'm ambivalent, personally. |
This was semi intentional, to make It is true that library-less dependencies are weird, so perhaps it makes sense to put the fix closer to the core, report an error if we see such a dependency and just assume, everywhere, that every dependency has a library target? |
Semi unrelated, but, while we are at it, perhaps it makes sense to add a dependency from a package on itself, while we are at it? That way clients won't have to deal with replacing |
I'm not very excited about making a hard error. I'm often wary of adding new errors since they can cause trouble, and the warning→error transition is a hassle. It would break any package that had It might help me if I knew who is currently using this information and for what purpose. In the past I've tried to use it, but it doesn't provide enough information for the things I wanted to do. The entries can't be (reliably) matched to the Package dependencies, so you can't tell what Kind they are, or anything else. My ideal situation would be to have access to the unit dependencies map.
I'm still of the position that these binary dependencies are useless information that is not actionable, and just requires all users to filter them out. I don't know what purpose they serve to know about a dependency that can't be used. |
☔ The latest upstream changes (presumably #6631) made this pull request unmergeable. Please resolve the merge conflicts. |
If a package has a dependency without a library target, the "name" field was showing up as null in `resolve.nodes.deps`. At this time (AFAIK), binary-only dependencies are always ignored. Instead of making users filter out this entry (or more commonly, crash), just don't include it.
a2fc5cf
to
c3f4b0d
Compare
Heh, hit this in rust-analyzer: rust-lang/rust-analyzer#979 The current PR definitely looks good, r=me. Adding a warning can done separately. |
let nodes = &meta["resolve"]["nodes"]; | ||
assert!(nodes[0]["deps"].as_array().unwrap().is_empty()); | ||
assert!(nodes[1]["deps"].as_array().unwrap().is_empty()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have a test for this (I remember dealing with this problem explicitelly) already. Might be a good idea to put .unwrap
on the name and run the test-suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried with an unwrap, but none of the tests failed.
Ping @Eh2406 or @alexcrichton, just wondering if we can make a decision on this. I see three options:
I still lean for 2, for the reasons outlined above. I don't think we have the list of use cases to properly do 3. |
I don't understand this well enough to have a deciding opinion. Looks like the knowledgeable people seem to like merging. |
I'd personally be fine with option 2 myself as recommended! Is this just waiting on an r+ otherwise? |
Yep. |
@bors: r+ |
📌 Commit a2fc5cf0241ff8841519fb8ca682a4b8f740640b has been approved by |
@bors r=alexcrichton |
📌 Commit c3f4b0d has been approved by |
cargo metadata: Don't show `null` deps. If a package has a dependency without a library target, the "name" field was showing up as null in `resolve.nodes.deps`. At this time (AFAIK), binary-only dependencies are always ignored. Instead of making users filter out this entry (or more commonly, crash), just don't include it.
☀️ Test successful - checks-travis, status-appveyor |
Update cargo Update cargo 22 commits in 0e35bd8af0ec72d3225c4819b330b94628f0e9d0..63231f438a2b5b84ccf319a5de22343ee0316323 2019-03-13 06:52:51 +0000 to 2019-03-27 12:26:45 +0000 - Code cleanup (rust-lang/cargo#6787) - Add cargo:rustc-link-arg to pass custom linker arguments (rust-lang/cargo#6298) - Testsuite: remove some unnecessary is_nightly checks. (rust-lang/cargo#6786) - cargo metadata: Don't show `null` deps. (rust-lang/cargo#6534) - Some fingerprint cleanup. (rust-lang/cargo#6785) - Fix fingerprint for canceled build script. (rust-lang/cargo#6782) - Canonicalize default target if it ends with `.json` (rust-lang/cargo#6778) - Fix setting `panic=unwind` compiling lib a extra time. (rust-lang/cargo#6781) - Always nicely show errors from crates.io if possible (rust-lang/cargo#6771) - Testsuite: Make `cwd()` relative to project root. (rust-lang/cargo#6768) - Allow `cargo fix` if gitignore matches root working dir. (rust-lang/cargo#6767) - Remove redundant imports (rust-lang/cargo#6763) - Handle backcompat hazard with `toml` crate (rust-lang/cargo#6761) - Fix spurious error in dirty_both_lib_and_test. (rust-lang/cargo#6756) - Update toml requirement from 0.4.2 to 0.5.0 (rust-lang/cargo#6760) - Reuse std::env::consts::EXE_SUFFIX (rust-lang/cargo#6758) - Proptest 0.9.1 (rust-lang/cargo#6753) - Don't need extern crate in 2018 (rust-lang/cargo#6752) - Release a jobserver token while locking a file (rust-lang/cargo#6748) - Minor doc fix for publish command synopsis (rust-lang/cargo#6749) - Stricter package change detection. (rust-lang/cargo#6740) - Fix resolving yanked crates when using a local registry. (rust-lang/cargo#6742)
If a package has a dependency without a library target, the "name" field was
showing up as null in
resolve.nodes.deps
. At this time (AFAIK), binary-onlydependencies are always ignored. Instead of making users filter out this entry
(or more commonly, crash), just don't include it.