Don't use CargoDocConfig struct

This commit is contained in:
5225225 2021-06-19 17:45:44 +01:00
parent 1919ce7ce5
commit 9e4c0e1e44
2 changed files with 5 additions and 16 deletions

View File

@ -2,7 +2,6 @@ use crate::core::{Shell, Workspace};
use crate::ops;
use crate::util::config::PathAndArgs;
use crate::util::CargoResult;
use serde::Deserialize;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
@ -16,13 +15,6 @@ pub struct DocOptions {
pub compile_opts: ops::CompileOptions,
}
#[derive(Deserialize)]
struct CargoDocConfig {
/// Browser to use to open docs. If this is unset, the value of the environment variable
/// `BROWSER` will be used.
browser: Option<PathAndArgs>,
}
/// Main method for `cargo doc`.
pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
let compilation = ops::compile(ws, &options.compile_opts)?;
@ -36,10 +28,8 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
.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))
let cfg: Option<PathAndArgs> = ws.config().get("doc.browser")?;
cfg.map(|path_args| (path_args.path.resolve_program(ws.config()), path_args.args))
};
let mut shell = ws.config().shell();

View File

@ -1188,13 +1188,12 @@ fn doc_extern_map_local() {
p.change_file(
".cargo/config.toml",
r#"
[doc.extern-map]
std = "local"
[doc.extern-map]
std = "local"
"#,
);
p.cargo("doc -Zrustdoc-map --open")
p.cargo("doc -v --no-deps -Zrustdoc-map --open")
.env("BROWSER", "echo")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])")