Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5225225 opened this issue Jun 1, 2021 · 1 comment · Fixed by #9531
Closed

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

5225225 opened this issue Jun 1, 2021 · 1 comment · Fixed by #9531
Labels

Comments

@5225225
Copy link
Contributor

5225225 commented Jun 1, 2021

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.

@5225225
Copy link
Contributor Author

5225225 commented Jun 1, 2021

Apparently it's because my .cargo/config.toml has

[doc.extern-map]
std = "local"

in it.

Removing this makes cargo doc --open work fine.

@bors bors closed this as completed in 4952979 Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants