Skip to content

Commit

Permalink
Auto merge of #13664 - epage:refactor-toml, r=weihanglo
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Mar 28, 2024
2 parents 3d9dea6 + 8a82df2 commit 97ed4ff
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 269 deletions.
6 changes: 6 additions & 0 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ pub enum EitherManifest {
}

impl EitherManifest {
pub fn warnings_mut(&mut self) -> &mut Warnings {
match self {
EitherManifest::Real(r) => r.warnings_mut(),
EitherManifest::Virtual(v) => v.warnings_mut(),
}
}
pub(crate) fn workspace_config(&self) -> &WorkspaceConfig {
match *self {
EitherManifest::Real(ref r) => r.workspace_config(),
Expand Down
4 changes: 4 additions & 0 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,17 @@ fn build_lock(ws: &Workspace<'_>, orig_pkg: &Package) -> CargoResult<String> {
let toml_manifest =
prepare_for_publish(orig_pkg.manifest().resolved_toml(), ws, orig_pkg.root())?;
let source_id = orig_pkg.package_id().source_id();
let mut warnings = Default::default();
let mut errors = Default::default();
let manifest = to_real_manifest(
contents.to_owned(),
document.clone(),
toml_manifest,
source_id,
orig_pkg.manifest_path(),
gctx,
&mut warnings,
&mut errors,
)?;
let new_pkg = Package::new(manifest, orig_pkg.manifest_path());

Expand Down
Loading

0 comments on commit 97ed4ff

Please sign in to comment.