@@ -161,7 +161,7 @@ fn parse_section(args: &ArgMatches) -> DepTable {
161
161
/// Clean up the workspace.dependencies, profile, patch, and replace sections of the root manifest
162
162
/// by removing dependencies which no longer have a reference to them.
163
163
fn gc_workspace ( workspace : & Workspace < ' _ > ) -> CargoResult < ( ) > {
164
- let mut manifest : toml_edit:: DocumentMut =
164
+ let mut workspace_manifest : toml_edit:: DocumentMut =
165
165
cargo_util:: paths:: read ( workspace. root_manifest ( ) ) ?. parse ( ) ?;
166
166
let mut is_modified = true ;
167
167
@@ -177,8 +177,8 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
177
177
178
178
let mut dependencies = members
179
179
. into_iter ( )
180
- . flat_map ( |( manifest , unstable_features) | {
181
- manifest
180
+ . flat_map ( |( member_manifest , unstable_features) | {
181
+ member_manifest
182
182
. get_sections ( )
183
183
. into_iter ( )
184
184
. flat_map ( move |( _, table) | {
@@ -190,7 +190,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
190
190
Dependency :: from_toml (
191
191
workspace. gctx ( ) ,
192
192
workspace. root ( ) ,
193
- & manifest . path ,
193
+ & member_manifest . path ,
194
194
& unstable_features,
195
195
key,
196
196
item,
@@ -203,7 +203,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
203
203
204
204
// Clean up the workspace.dependencies section and replace instances of
205
205
// workspace dependencies with their definitions
206
- if let Some ( toml_edit:: Item :: Table ( deps_table) ) = manifest
206
+ if let Some ( toml_edit:: Item :: Table ( deps_table) ) = workspace_manifest
207
207
. get_mut ( "workspace" )
208
208
. and_then ( |t| t. get_mut ( "dependencies" ) )
209
209
{
@@ -246,7 +246,9 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
246
246
// Example tables:
247
247
// - profile.dev.package.foo
248
248
// - profile.release.package."foo:2.1.0"
249
- if let Some ( toml_edit:: Item :: Table ( profile_section_table) ) = manifest. get_mut ( "profile" ) {
249
+ if let Some ( toml_edit:: Item :: Table ( profile_section_table) ) =
250
+ workspace_manifest. get_mut ( "profile" )
251
+ {
250
252
profile_section_table. set_implicit ( true ) ;
251
253
252
254
for ( _, item) in profile_section_table. iter_mut ( ) {
@@ -280,7 +282,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
280
282
}
281
283
282
284
// Clean up the replace section
283
- if let Some ( toml_edit:: Item :: Table ( table) ) = manifest . get_mut ( "replace" ) {
285
+ if let Some ( toml_edit:: Item :: Table ( table) ) = workspace_manifest . get_mut ( "replace" ) {
284
286
table. set_implicit ( true ) ;
285
287
286
288
for ( key, item) in table. iter_mut ( ) {
@@ -298,7 +300,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
298
300
if is_modified {
299
301
cargo_util:: paths:: write_atomic (
300
302
workspace. root_manifest ( ) ,
301
- manifest . to_string ( ) . as_bytes ( ) ,
303
+ workspace_manifest . to_string ( ) . as_bytes ( ) ,
302
304
) ?;
303
305
}
304
306
@@ -340,12 +342,12 @@ fn spec_has_match(
340
342
341
343
/// Removes unused patches from the manifest
342
344
fn gc_unused_patches ( workspace : & Workspace < ' _ > , resolve : & Resolve ) -> CargoResult < bool > {
343
- let mut manifest : toml_edit:: DocumentMut =
345
+ let mut workspace_manifest : toml_edit:: DocumentMut =
344
346
cargo_util:: paths:: read ( workspace. root_manifest ( ) ) ?. parse ( ) ?;
345
347
let mut modified = false ;
346
348
347
349
// Clean up the patch section
348
- if let Some ( toml_edit:: Item :: Table ( patch_section_table) ) = manifest . get_mut ( "patch" ) {
350
+ if let Some ( toml_edit:: Item :: Table ( patch_section_table) ) = workspace_manifest . get_mut ( "patch" ) {
349
351
patch_section_table. set_implicit ( true ) ;
350
352
351
353
for ( _, item) in patch_section_table. iter_mut ( ) {
@@ -383,7 +385,10 @@ fn gc_unused_patches(workspace: &Workspace<'_>, resolve: &Resolve) -> CargoResul
383
385
}
384
386
385
387
if modified {
386
- cargo_util:: paths:: write ( workspace. root_manifest ( ) , manifest. to_string ( ) . as_bytes ( ) ) ?;
388
+ cargo_util:: paths:: write (
389
+ workspace. root_manifest ( ) ,
390
+ workspace_manifest. to_string ( ) . as_bytes ( ) ,
391
+ ) ?;
387
392
}
388
393
389
394
Ok ( modified)
0 commit comments