Skip to content

Commit 6ebd1ae

Browse files
committed
refactor(remove): Clarify variable names
1 parent 589d099 commit 6ebd1ae

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/bin/cargo/commands/remove.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ fn parse_section(args: &ArgMatches) -> DepTable {
161161
/// Clean up the workspace.dependencies, profile, patch, and replace sections of the root manifest
162162
/// by removing dependencies which no longer have a reference to them.
163163
fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
164-
let mut manifest: toml_edit::DocumentMut =
164+
let mut workspace_manifest: toml_edit::DocumentMut =
165165
cargo_util::paths::read(workspace.root_manifest())?.parse()?;
166166
let mut is_modified = true;
167167

@@ -177,8 +177,8 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
177177

178178
let mut dependencies = members
179179
.into_iter()
180-
.flat_map(|(manifest, unstable_features)| {
181-
manifest
180+
.flat_map(|(member_manifest, unstable_features)| {
181+
member_manifest
182182
.get_sections()
183183
.into_iter()
184184
.flat_map(move |(_, table)| {
@@ -190,7 +190,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
190190
Dependency::from_toml(
191191
workspace.gctx(),
192192
workspace.root(),
193-
&manifest.path,
193+
&member_manifest.path,
194194
&unstable_features,
195195
key,
196196
item,
@@ -203,7 +203,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
203203

204204
// Clean up the workspace.dependencies section and replace instances of
205205
// 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
207207
.get_mut("workspace")
208208
.and_then(|t| t.get_mut("dependencies"))
209209
{
@@ -246,7 +246,9 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
246246
// Example tables:
247247
// - profile.dev.package.foo
248248
// - 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+
{
250252
profile_section_table.set_implicit(true);
251253

252254
for (_, item) in profile_section_table.iter_mut() {
@@ -280,7 +282,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
280282
}
281283

282284
// 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") {
284286
table.set_implicit(true);
285287

286288
for (key, item) in table.iter_mut() {
@@ -298,7 +300,7 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
298300
if is_modified {
299301
cargo_util::paths::write_atomic(
300302
workspace.root_manifest(),
301-
manifest.to_string().as_bytes(),
303+
workspace_manifest.to_string().as_bytes(),
302304
)?;
303305
}
304306

@@ -340,12 +342,12 @@ fn spec_has_match(
340342

341343
/// Removes unused patches from the manifest
342344
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 =
344346
cargo_util::paths::read(workspace.root_manifest())?.parse()?;
345347
let mut modified = false;
346348

347349
// 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") {
349351
patch_section_table.set_implicit(true);
350352

351353
for (_, item) in patch_section_table.iter_mut() {
@@ -383,7 +385,10 @@ fn gc_unused_patches(workspace: &Workspace<'_>, resolve: &Resolve) -> CargoResul
383385
}
384386

385387
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+
)?;
387392
}
388393

389394
Ok(modified)

0 commit comments

Comments
 (0)