Skip to content

Commit

Permalink
Pass --edition after --crate-name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dtolnay committed Dec 14, 2019
1 parent 19a0de2 commit 9aa65c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
13 changes: 2 additions & 11 deletions src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,7 @@ impl<'cfg> Compilation<'cfg> {
}

/// See `process`.
pub fn rustc_process(
&self,
pkg: &Package,
target: &Target,
is_primary: bool,
) -> CargoResult<ProcessBuilder> {
pub fn rustc_process(&self, pkg: &Package, is_primary: bool) -> CargoResult<ProcessBuilder> {
let rustc = if is_primary {
self.primary_unit_rustc_process
.clone()
Expand All @@ -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`.
Expand Down
11 changes: 7 additions & 4 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -538,9 +538,7 @@ fn prepare_rustc<'a, 'cfg>(
) -> CargoResult<ProcessBuilder> {
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)?;
Expand Down Expand Up @@ -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))?;

Expand Down

0 comments on commit 9aa65c5

Please sign in to comment.