From 9aa65c556c189e03b59228e125ed6a5c79ac9aaa Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 13 Dec 2019 19:10:15 -0800 Subject: [PATCH] Pass --edition after --crate-name This PR swaps the order of the --edition and --crate-name args in the rustc invocation. Before: rustc --edition=2018 --crate-name cargo ... After: rustc --crate-name cargo --edition=2018 ... The crate name is a lot more relevant when looking at processes in top for example, and should appear first. --- src/cargo/core/compiler/compilation.rs | 13 ++----------- src/cargo/core/compiler/mod.rs | 11 +++++++---- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/cargo/core/compiler/compilation.rs b/src/cargo/core/compiler/compilation.rs index 98b17f31587..f382d03fabf 100644 --- a/src/cargo/core/compiler/compilation.rs +++ b/src/cargo/core/compiler/compilation.rs @@ -119,12 +119,7 @@ impl<'cfg> Compilation<'cfg> { } /// See `process`. - pub fn rustc_process( - &self, - pkg: &Package, - target: &Target, - is_primary: bool, - ) -> CargoResult { + pub fn rustc_process(&self, pkg: &Package, is_primary: bool) -> CargoResult { let rustc = if is_primary { self.primary_unit_rustc_process .clone() @@ -133,11 +128,7 @@ impl<'cfg> Compilation<'cfg> { self.rustc_process.clone() }; - let mut p = self.fill_env(rustc, pkg, true)?; - if target.edition() != Edition::Edition2015 { - p.arg(format!("--edition={}", target.edition())); - } - Ok(p) + self.fill_env(rustc, pkg, true) } /// See `process`. diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index e44356e98ac..986ff591776 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -43,7 +43,7 @@ use self::unit_dependencies::UnitDep; pub use crate::core::compiler::unit::{Unit, UnitInterner}; use crate::core::manifest::TargetSourcePath; use crate::core::profiles::{Lto, PanicStrategy, Profile}; -use crate::core::{Feature, InternedString, PackageId, Target}; +use crate::core::{Edition, Feature, InternedString, PackageId, Target}; use crate::util::errors::{self, CargoResult, CargoResultExt, Internal, ProcessError}; use crate::util::machine_message::Message; use crate::util::paths; @@ -538,9 +538,7 @@ fn prepare_rustc<'a, 'cfg>( ) -> CargoResult { let is_primary = cx.is_primary_package(unit); - let mut base = cx - .compilation - .rustc_process(unit.pkg, unit.target, is_primary)?; + let mut base = cx.compilation.rustc_process(unit.pkg, is_primary)?; base.inherit_jobserver(&cx.jobserver); build_base_args(cx, &mut base, unit, crate_types)?; build_deps_args(&mut base, cx, unit)?; @@ -714,6 +712,11 @@ fn build_base_args<'a, 'cfg>( cmd.arg("--crate-name").arg(&unit.target.crate_name()); + let edition = unit.target.edition(); + if edition != Edition::Edition2015 { + cmd.arg(format!("--edition={}", edition)); + } + add_path_args(bcx, unit, cmd); add_error_format_and_color(cx, cmd, cx.rmeta_required(unit))?;