Skip to content

Commit 97ed4ff

Browse files
committed
Auto merge of #13664 - epage:refactor-toml, 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
2 parents 3d9dea6 + 8a82df2 commit 97ed4ff

File tree

4 files changed

+265
-269
lines changed

4 files changed

+265
-269
lines changed

src/cargo/core/manifest.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ pub enum EitherManifest {
2828
}
2929

3030
impl EitherManifest {
31+
pub fn warnings_mut(&mut self) -> &mut Warnings {
32+
match self {
33+
EitherManifest::Real(r) => r.warnings_mut(),
34+
EitherManifest::Virtual(v) => v.warnings_mut(),
35+
}
36+
}
3137
pub(crate) fn workspace_config(&self) -> &WorkspaceConfig {
3238
match *self {
3339
EitherManifest::Real(ref r) => r.workspace_config(),

src/cargo/ops/cargo_package.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,17 @@ fn build_lock(ws: &Workspace<'_>, orig_pkg: &Package) -> CargoResult<String> {
458458
let toml_manifest =
459459
prepare_for_publish(orig_pkg.manifest().resolved_toml(), ws, orig_pkg.root())?;
460460
let source_id = orig_pkg.package_id().source_id();
461+
let mut warnings = Default::default();
462+
let mut errors = Default::default();
461463
let manifest = to_real_manifest(
462464
contents.to_owned(),
463465
document.clone(),
464466
toml_manifest,
465467
source_id,
466468
orig_pkg.manifest_path(),
467469
gctx,
470+
&mut warnings,
471+
&mut errors,
468472
)?;
469473
let new_pkg = Package::new(manifest, orig_pkg.manifest_path());
470474

0 commit comments

Comments
 (0)