Skip to content

cargo doc --open fails with 'already borrowed: BorrowMutError' #9530

@ghost

Description

Problem

I'm unable to run cargo doc --open without

thread 'main' panicked at 'already borrowed: BorrowMutError', src/tools/cargo/src/cargo/util/config/mod.rs:342:20
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c1e8f3a5857c3c8d095fd212acc6ed442f4cc58b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c1e8f3a5857c3c8d095fd212acc6ed442f4cc58b/library/core/src/panicking.rs:92:14
   2: core::result::unwrap_failed
             at /rustc/c1e8f3a5857c3c8d095fd212acc6ed442f4cc58b/library/core/src/result.rs:1355:5
   3: cargo::util::config::de::ConfigMapAccess::new_struct
   4: <cargo::util::config::de::Deserializer as serde::de::Deserializer>::deserialize_struct
   5: cargo::util::config::Config::get
   6: cargo::ops::cargo_doc::doc
   7: cargo::commands::doc::exec
   8: cargo::cli::main
   9: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Steps

  1. Go to any cargo project
  2. Run cargo doc --open

Possible Solution(s)

I've already implemented a fix for this, to be careful to not keep the result of ws.config() around before we call ws.config() again, will make a pull request for that shortly.

Notes

Output of cargo version:

Happens on cargo 1.54.0-nightly (e931e4796 2021-05-24) as well as the latest git master, being checked out to 0cecbd6.

That being said, I have no idea why the tests didn't catch this. I do have CARGO_TARGET_DIR set to have a global target directory, but even unsetting that and running cargo run -- doc --open in the cargo git repo fails.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions