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::ops;
use crate::util::config::PathAndArgs; use crate::util::config::PathAndArgs;
use crate::util::CargoResult; use crate::util::CargoResult;
use serde::Deserialize;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
@ -16,13 +15,6 @@ pub struct DocOptions {
pub compile_opts: ops::CompileOptions, 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`. /// Main method for `cargo doc`.
pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> { pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
let compilation = ops::compile(ws, &options.compile_opts)?; let compilation = ops::compile(ws, &options.compile_opts)?;
@ -36,10 +28,8 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
.join("index.html"); .join("index.html");
if path.exists() { if path.exists() {
let config_browser = { let config_browser = {
let cfg = ws.config().get::<CargoDocConfig>("doc")?; let cfg: Option<PathAndArgs> = ws.config().get("doc.browser")?;
cfg.map(|path_args| (path_args.path.resolve_program(ws.config()), path_args.args))
cfg.browser
.map(|path_args| (path_args.path.resolve_program(ws.config()), path_args.args))
}; };
let mut shell = ws.config().shell(); let mut shell = ws.config().shell();

View File

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