Skip to content

Commit 9882ab3

Browse files
committed
refactor(toml): Proces unused keys on Manifest
1 parent 0305ad3 commit 9882ab3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,6 @@ pub fn to_real_manifest(
489489
let mut warnings = vec![];
490490
let mut errors = vec![];
491491

492-
warn_on_unused(&original_toml._unused_keys, &mut warnings);
493-
494492
// Parse features first so they will be available when parsing other parts of the TOML.
495493
let empty = Vec::new();
496494
let cargo_features = original_toml.cargo_features.as_ref().unwrap_or(&empty);
@@ -1221,6 +1219,7 @@ pub fn to_real_manifest(
12211219
.to_owned(),
12221220
);
12231221
}
1222+
warn_on_unused(&manifest.original_toml()._unused_keys, &mut warnings);
12241223
for warning in warnings {
12251224
manifest.warnings_mut().add_warning(warning);
12261225
}
@@ -1291,6 +1290,8 @@ fn to_virtual_manifest(
12911290
) -> CargoResult<VirtualManifest> {
12921291
let root = manifest_file.parent().unwrap();
12931292

1293+
let mut resolved_toml = original_toml.clone();
1294+
12941295
if let Some(deps) = original_toml
12951296
.workspace
12961297
.as_ref()
@@ -1316,7 +1317,7 @@ fn to_virtual_manifest(
13161317
let cargo_features = original_toml.cargo_features.as_ref().unwrap_or(&empty);
13171318
let features = Features::new(cargo_features, gctx, &mut warnings, source_id.is_path())?;
13181319

1319-
warn_on_unused(&original_toml._unused_keys, &mut warnings);
1320+
resolved_toml._unused_keys = Default::default();
13201321

13211322
let (replace, patch) = {
13221323
let mut manifest_ctx = ManifestContext {
@@ -1355,7 +1356,6 @@ fn to_virtual_manifest(
13551356
bail!("virtual manifests must be configured with [workspace]");
13561357
}
13571358
};
1358-
let resolved_toml = original_toml.clone();
13591359
let mut manifest = VirtualManifest::new(
13601360
Rc::new(contents),
13611361
Rc::new(document),
@@ -1367,6 +1367,8 @@ fn to_virtual_manifest(
13671367
features,
13681368
resolve_behavior,
13691369
);
1370+
1371+
warn_on_unused(&manifest.original_toml()._unused_keys, &mut warnings);
13701372
for warning in warnings {
13711373
manifest.warnings_mut().add_warning(warning);
13721374
}

0 commit comments

Comments
 (0)