Skip to content

Commit b765fad

Browse files
committed
Make edition comparing code consistent
Rather than sometimes comparing equality, sometimes using ordering and sometimes pattern matching, consistently compare by equalty to 2015.
1 parent ff7f2bc commit b765fad

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/cargo/ops/cargo_install.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,20 @@ fn install_one(
228228
let pkg = ws.current()?;
229229

230230
if from_cwd {
231-
match pkg.manifest().edition() {
232-
Edition::Edition2015 => config.shell().warn(
231+
if pkg.manifest().edition() == Edition::Edition2015 {
232+
config.shell().warn(
233233
"Using `cargo install` to install the binaries for the \
234234
package in current working directory is deprecated, \
235235
use `cargo install --path .` instead. \
236236
Use `cargo build` if you want to simply build the package.",
237-
)?,
238-
Edition::Edition2018 => failure::bail!(
237+
)?
238+
} else {
239+
failure::bail!(
239240
"Using `cargo install` to install the binaries for the \
240241
package in current working directory is no longer supported, \
241242
use `cargo install --path .` instead. \
242243
Use `cargo build` if you want to simply build the package."
243-
),
244+
)
244245
}
245246
};
246247

src/cargo/util/toml/targets.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn clean_lib(
178178
(None, Some(path)) => path,
179179
(None, None) => {
180180
let legacy_path = package_root.join("src").join(format!("{}.rs", lib.name()));
181-
if edition < Edition::Edition2018 && legacy_path.exists() {
181+
if edition == Edition::Edition2015 && legacy_path.exists() {
182182
warnings.push(format!(
183183
"path `{}` was erroneously implicitly accepted for library `{}`,\n\
184184
please rename the file to `src/lib.rs` or set lib.path in Cargo.toml",
@@ -661,9 +661,8 @@ fn toml_targets_and_inferred(
661661

662662
let autodiscover = match autodiscover {
663663
Some(autodiscover) => autodiscover,
664-
None => match edition {
665-
Edition::Edition2018 => true,
666-
Edition::Edition2015 => {
664+
None =>
665+
if edition == Edition::Edition2015 {
667666
if !rem_targets.is_empty() {
668667
let mut rem_targets_str = String::new();
669668
for t in rem_targets.iter() {
@@ -694,8 +693,9 @@ https://github.com/rust-lang/cargo/issues/5330",
694693
));
695694
};
696695
false
696+
} else {
697+
true
697698
}
698-
},
699699
};
700700

701701
if autodiscover {
@@ -805,7 +805,7 @@ fn target_path(
805805
match (first, second) {
806806
(Some(path), None) => Ok(path),
807807
(None, None) | (Some(_), Some(_)) => {
808-
if edition < Edition::Edition2018 {
808+
if edition == Edition::Edition2015 {
809809
if let Some(path) = legacy_path(target) {
810810
return Ok(path);
811811
}

0 commit comments

Comments
 (0)