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

Fix BorrowMutError when calling cargo doc --open #9531

Merged
merged 4 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/cargo/ops/cargo_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
.join(&name)
.join("index.html");
if path.exists() {
let config_browser = {
let cfg = ws.config().get::<CargoDocConfig>("doc")?;

cfg.browser
.map(|path_args| (path_args.path.resolve_program(ws.config()), path_args.args))
5225225 marked this conversation as resolved.
Show resolved Hide resolved
};

let mut shell = ws.config().shell();
shell.status("Opening", path.display())?;
let cfg = ws.config().get::<CargoDocConfig>("doc")?;
open_docs(
&path,
&mut shell,
cfg.browser
.map(|path_args| (path_args.path.resolve_program(ws.config()), path_args.args)),
)?;
open_docs(&path, &mut shell, config_browser)?;
}
}

Expand Down
34 changes: 34 additions & 0 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,40 @@ fn doc_workspace_open_help_message() {
.run();
}

#[cargo_test]
#[cfg(not(windows))] // `echo` may not be available
fn doc_extern_map_local() {
assert!(is_nightly());
5225225 marked this conversation as resolved.
Show resolved Hide resolved

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
"#,
)
.file("src/lib.rs", "")
.build();

p.change_file(
".cargo/config.toml",
r#"
[doc.extern-map]
std = "local"
"#,
);


p.cargo("doc -Zrustdoc-map --open")
.env("BROWSER", "echo")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])")
.with_stderr_does_not_contain("warning: unused config key `doc.extern-map` [..]")
5225225 marked this conversation as resolved.
Show resolved Hide resolved
.run();
}

#[cargo_test]
#[cfg(not(windows))] // `echo` may not be available
fn doc_workspace_open_different_library_and_package_names() {
Expand Down