Skip to content

Commit d138d37

Browse files
committed
Auto merge of #7710 - dtolnay:argorder, r=alexcrichton
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.
2 parents 414ec70 + 9aa65c5 commit d138d37

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/cargo/core/compiler/compilation.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,7 @@ impl<'cfg> Compilation<'cfg> {
119119
}
120120

121121
/// See `process`.
122-
pub fn rustc_process(
123-
&self,
124-
pkg: &Package,
125-
target: &Target,
126-
is_primary: bool,
127-
) -> CargoResult<ProcessBuilder> {
122+
pub fn rustc_process(&self, pkg: &Package, is_primary: bool) -> CargoResult<ProcessBuilder> {
128123
let rustc = if is_primary {
129124
self.primary_unit_rustc_process
130125
.clone()
@@ -133,11 +128,7 @@ impl<'cfg> Compilation<'cfg> {
133128
self.rustc_process.clone()
134129
};
135130

136-
let mut p = self.fill_env(rustc, pkg, true)?;
137-
if target.edition() != Edition::Edition2015 {
138-
p.arg(format!("--edition={}", target.edition()));
139-
}
140-
Ok(p)
131+
self.fill_env(rustc, pkg, true)
141132
}
142133

143134
/// See `process`.

src/cargo/core/compiler/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use self::unit_dependencies::UnitDep;
4343
pub use crate::core::compiler::unit::{Unit, UnitInterner};
4444
use crate::core::manifest::TargetSourcePath;
4545
use crate::core::profiles::{Lto, PanicStrategy, Profile};
46-
use crate::core::{Feature, InternedString, PackageId, Target};
46+
use crate::core::{Edition, Feature, InternedString, PackageId, Target};
4747
use crate::util::errors::{self, CargoResult, CargoResultExt, Internal, ProcessError};
4848
use crate::util::machine_message::Message;
4949
use crate::util::paths;
@@ -538,9 +538,7 @@ fn prepare_rustc<'a, 'cfg>(
538538
) -> CargoResult<ProcessBuilder> {
539539
let is_primary = cx.is_primary_package(unit);
540540

541-
let mut base = cx
542-
.compilation
543-
.rustc_process(unit.pkg, unit.target, is_primary)?;
541+
let mut base = cx.compilation.rustc_process(unit.pkg, is_primary)?;
544542
base.inherit_jobserver(&cx.jobserver);
545543
build_base_args(cx, &mut base, unit, crate_types)?;
546544
build_deps_args(&mut base, cx, unit)?;
@@ -714,6 +712,11 @@ fn build_base_args<'a, 'cfg>(
714712

715713
cmd.arg("--crate-name").arg(&unit.target.crate_name());
716714

715+
let edition = unit.target.edition();
716+
if edition != Edition::Edition2015 {
717+
cmd.arg(format!("--edition={}", edition));
718+
}
719+
717720
add_path_args(bcx, unit, cmd);
718721
add_error_format_and_color(cx, cmd, cx.rmeta_required(unit))?;
719722

0 commit comments

Comments
 (0)