-
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
fix(toml): Warn on unused workspace.dependencies keys on virtual workspaces #13664
Conversation
This is the only error we do this for and we have the context for what manifest we are parsing. By removing this, it makes it easier to adjust lifetimes in the short term.
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.
Feel free to address nits or r=weihanglo
as-is.
src/cargo/util/toml/mod.rs
Outdated
|
||
let summary = Summary::new( | ||
pkgid, | ||
deps, | ||
&original_toml | ||
.features | ||
.as_ref() | ||
.unwrap_or(&empty_features) | ||
.unwrap_or(&Default::default()) |
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.
nit
.unwrap_or(&Default::default()) | |
.unwrap_or_default() |
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.
There is no impl Default for &T
in this case
@@ -1173,7 +1171,7 @@ fn resolve_and_validate_dependencies( | |||
let mut resolved = resolved; | |||
if let manifest::TomlDependency::Detailed(ref mut d) = resolved { | |||
if d.public.is_some() { | |||
if matches!(dep.kind(), DepKind::Normal) { | |||
if matches!(kind, None) { |
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.
nit: matches!
against an Option looks pretty not idiomatic to me
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.
BTW it seems like non of the usage of resolve_and_validate_dependencies
receives a DepKind::Normal
. I wonder if we could remove the Option
.
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.
This is a high churn area in a follow up PR, can we defer this?
let mut warnings = Default::default(); | ||
let mut errors = Default::default(); |
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.
nit: Default::default
is used here and in read_manifest
we use vec![]
. Any reason for the inconsistency?
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.
Not really but this will be going away in the next PR
@bors r=weihanglo |
fix(toml): Warn on unused workspace.dependencies keys on virtual workspaces ### What does this PR try to resolve? This splits out refactors that build on #13589 in preparation for resolving #13456. As part of those refactors, I noticed an inconsistency on when we warn for unused keys. We have parallel code paths between `to_virtual_manifest` and `to_real_manifest` and only one got updated on a change. This syncs them up. Hopefully the end state this builds to will reduce duplication. ### How should we test and review this PR? ### Additional information
💔 Test failed - checks-actions |
@bors retry |
Resolver prop test
|
☀️ Test successful - checks-actions |
This resolves feedback from rust-lang#13664
refactor(package): Simplify getting of published Manifest ### What does this PR try to resolve? This is a parallel effort to #13664 in an effort to #13456 This abstracts away the logic for getting the published version of `Cargo.toml` so we can more easily change the APIs that were previously exposed ### How should we test and review this PR? ### Additional information
Update cargo 8 commits in 499a61ce7a0fc6a72040084862a68b2603e770e8..a59aba136aab5510c16b0750a36cbd9916f91796 2024-03-26 04:17:04 +0000 to 2024-03-28 21:21:41 +0000 - refactor(package): Simplify getting of published Manifest (rust-lang/cargo#13666) - fix(toml): Warn on unused workspace.dependencies keys on virtual workspaces (rust-lang/cargo#13664) - docs: clarify `--locked` ensures Cargo uses dependency versions in lockfile (rust-lang/cargo#13665) - RUSTC_WORKSPACE_WRAPPER: clarify docs (rust-lang/cargo#13648) - fix(add): Preserve comments when updating simple deps (rust-lang/cargo#13655) - fix(generate-lockfile): hold lock before querying index (rust-lang/cargo#13657) - test: Add asserts to catch BorrowMutError's (rust-lang/cargo#13651) - Publish test crates (rust-lang/cargo#13418) r? ghost
Update cargo 8 commits in 499a61ce7a0fc6a72040084862a68b2603e770e8..a59aba136aab5510c16b0750a36cbd9916f91796 2024-03-26 04:17:04 +0000 to 2024-03-28 21:21:41 +0000 - refactor(package): Simplify getting of published Manifest (rust-lang/cargo#13666) - fix(toml): Warn on unused workspace.dependencies keys on virtual workspaces (rust-lang/cargo#13664) - docs: clarify `--locked` ensures Cargo uses dependency versions in lockfile (rust-lang/cargo#13665) - RUSTC_WORKSPACE_WRAPPER: clarify docs (rust-lang/cargo#13648) - fix(add): Preserve comments when updating simple deps (rust-lang/cargo#13655) - fix(generate-lockfile): hold lock before querying index (rust-lang/cargo#13657) - test: Add asserts to catch BorrowMutError's (rust-lang/cargo#13651) - Publish test crates (rust-lang/cargo#13418) r? ghost
refactor(toml): Split out an explicit step to resolve `Cargo.toml` ### What does this PR try to resolve? This builds on #13664 and #13666. Currently, once we have deserialized `Cargo.toml`, we pass it to a large machinery (`to_real_manifest`, `to_virtual_manifest`) so that - `Cargo.toml` is resolved - `Summary` is created - `Manifest` is created This splits out the resolving of `Cargo.toml` which is mostly workspace inheritance today. While splitting logic conjoined like this can be a bit messy in the short term, the hope is that overall this makes the logic easier to follow (more condensed, focused sections to view; more explicit inputs/outputs). In particular, I hope that this will make it clearer and easier to shift more logic into the resolving step, specifically the inferring of build targets for #13456. ### How should we test and review this PR? This is broken up into very small steps in the hope that it makes it easier to analyze a step. ### Additional information
What does this PR try to resolve?
This splits out refactors that build on #13589 in preparation for resolving #13456.
As part of those refactors, I noticed an inconsistency on when we warn for unused keys. We have parallel code paths between
to_virtual_manifest
andto_real_manifest
and only one got updated on a change. This syncs them up. Hopefully the end state this builds to will reduce duplication.How should we test and review this PR?
Additional information