From 27424e2dbaf5ff4ee53da92713d2b4ea04804df6 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sun, 18 Nov 2018 18:32:54 +0000 Subject: [PATCH] Use kebab-case for CompileMode, & discard some info --- src/cargo/core/compiler/build_config.rs | 22 +++++++++++++++++++++- tests/testsuite/build_plan.rs | 12 ++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/cargo/core/compiler/build_config.rs b/src/cargo/core/compiler/build_config.rs index bb25de07e..2de8fb575 100644 --- a/src/cargo/core/compiler/build_config.rs +++ b/src/cargo/core/compiler/build_config.rs @@ -1,6 +1,8 @@ use std::path::Path; use std::cell::RefCell; +use serde::ser; + use util::{CargoResult, CargoResultExt, Config, RustfixDiagnosticServer}; /// Configuration information for a rustc build. @@ -111,7 +113,7 @@ pub enum MessageFormat { /// `compile_ws` to tell it the general execution strategy. This influences /// the default targets selected. The other use is in the `Unit` struct /// to indicate what is being done with a specific target. -#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash, PartialOrd, Ord)] pub enum CompileMode { /// A target being built for a test. Test, @@ -136,6 +138,24 @@ pub enum CompileMode { RunCustomBuild, } +impl ser::Serialize for CompileMode { + fn serialize(&self, s: S) -> Result + where + S: ser::Serializer, + { + use self::CompileMode::*; + match *self { + Test => "test".serialize(s), + Build => "build".serialize(s), + Check { .. } => "check".serialize(s), + Bench => "bench".serialize(s), + Doc { .. } => "doc".serialize(s), + Doctest => "doctest".serialize(s), + RunCustomBuild => "run-custom-build".serialize(s), + } + } +} + impl CompileMode { /// Returns true if the unit is being checked. pub fn is_check(self) -> bool { diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs index c4ed1e098..7b520cfd6 100644 --- a/tests/testsuite/build_plan.rs +++ b/tests/testsuite/build_plan.rs @@ -29,7 +29,7 @@ fn cargo_build_plan_simple() { "package_version": "0.5.0", "program": "rustc", "target_kind": ["bin"], - "compile_mode": "Build" + "compile_mode": "build" } ] } @@ -88,7 +88,7 @@ fn cargo_build_plan_single_dep() { "package_version": "0.0.1", "program": "rustc", "target_kind": ["lib"], - "compile_mode": "Build" + "compile_mode": "build" }, { "args": "{...}", @@ -104,7 +104,7 @@ fn cargo_build_plan_single_dep() { "package_version": "0.5.0", "program": "rustc", "target_kind": ["lib"], - "compile_mode": "Build" + "compile_mode": "build" } ] } @@ -152,7 +152,7 @@ fn cargo_build_plan_build_script() { "package_version": "0.5.0", "program": "rustc", "target_kind": ["custom-build"], - "compile_mode": "Build" + "compile_mode": "build" }, { "args": "{...}", @@ -166,7 +166,7 @@ fn cargo_build_plan_build_script() { "package_version": "0.5.0", "program": "[..]/build-script-build", "target_kind": ["custom-build"], - "compile_mode": "RunCustomBuild" + "compile_mode": "run-custom-build" }, { "args": "{...}", @@ -180,7 +180,7 @@ fn cargo_build_plan_build_script() { "package_version": "0.5.0", "program": "rustc", "target_kind": ["bin"], - "compile_mode": "Build" + "compile_mode": "build" } ] }