message: Add `remove_from_table` manifest util
  Needed for `cargo remove`.
diff: @@ -368,6 +368,26 @@ impl LocalManifest {
  Ok(())
  }
  + /// Remove entry from a Cargo.toml.
  + pub fn remove_from_table(&mut self, table_path: &[String], name: &str) -> CargoResult<()> {
  + let parent_table = self.get_table_mut(table_path)?;
  +
  + let dep = parent_table
  + .get_mut(name)
  + .filter(|t| !t.is_none())
  + .ok_or_else(|| non_existent_dependency_err(name, table_path.join(".")))?;
  +
  + // remove the dependency
  + *dep = toml_edit::Item::None;
  +
  + // remove table if empty
  + if parent_table.as_table_like().unwrap().is_empty() {
  + *parent_table = toml_edit::Item::None;
  + }
  +
  + Ok(())
  + }
  +
  /// Remove references to `dep_key` if its no longer present.
  pub fn gc_dep(&mut self, dep_key: &str) {
  let explicit_dep_activation = self.is_explicit_dep_activation(dep_key);
  @@ -517,3 +537,10 @@ fn parse_manifest_err() -> anyhow::Error {
  fn non_existent_table_err(table: impl std::fmt::Display) -> anyhow::Error {
  anyhow::format_err!("the table `{table}` could not be found.")
  }
  +
  +fn non_existent_dependency_err(
  + name: impl std::fmt::Display,
  + table: impl std::fmt::Display,
  +) -> anyhow::Error {
  + anyhow::format_err!("the dependency `{name}` could not be found in `{table}`.")
  +}
  