]> git.proxmox.com Git - cargo.git/commitdiff
Make edition comparing code consistent
authorDale Wijnand <dale.wijnand@gmail.com>
Mon, 17 Dec 2018 08:11:20 +0000 (08:11 +0000)
committerDale Wijnand <dale.wijnand@gmail.com>
Mon, 17 Dec 2018 08:12:24 +0000 (08:12 +0000)
Rather than sometimes comparing equality, sometimes using ordering and
sometimes pattern matching, consistently compare by equalty to 2015.

src/cargo/ops/cargo_install.rs
src/cargo/util/toml/targets.rs

index dccc5e8fbb875fb9004650d361c467bbbc0312fb..dd1523a1ee06998aeb390916d6ffae97e0a528ba 100644 (file)
@@ -228,19 +228,20 @@ fn install_one(
     let pkg = ws.current()?;
 
     if from_cwd {
-        match pkg.manifest().edition() {
-            Edition::Edition2015 => config.shell().warn(
+        if pkg.manifest().edition() == Edition::Edition2015 {
+            config.shell().warn(
                 "Using `cargo install` to install the binaries for the \
                  package in current working directory is deprecated, \
                  use `cargo install --path .` instead. \
                  Use `cargo build` if you want to simply build the package.",
-            )?,
-            Edition::Edition2018 => failure::bail!(
+            )?
+        } else {
+            failure::bail!(
                 "Using `cargo install` to install the binaries for the \
                  package in current working directory is no longer supported, \
                  use `cargo install --path .` instead. \
                  Use `cargo build` if you want to simply build the package."
-            ),
+            )
         }
     };
 
index 3f625cb59f15c39236a9bc9d64d3e89034dc4a9e..dd81b715340317fa000a06e0165b30c48d4bb5c1 100644 (file)
@@ -178,7 +178,7 @@ fn clean_lib(
         (None, Some(path)) => path,
         (None, None) => {
             let legacy_path = package_root.join("src").join(format!("{}.rs", lib.name()));
-            if edition < Edition::Edition2018 && legacy_path.exists() {
+            if edition == Edition::Edition2015 && legacy_path.exists() {
                 warnings.push(format!(
                     "path `{}` was erroneously implicitly accepted for library `{}`,\n\
                      please rename the file to `src/lib.rs` or set lib.path in Cargo.toml",
@@ -661,9 +661,8 @@ fn toml_targets_and_inferred(
 
             let autodiscover = match autodiscover {
                 Some(autodiscover) => autodiscover,
-                None => match edition {
-                    Edition::Edition2018 => true,
-                    Edition::Edition2015 => {
+                None =>
+                    if edition == Edition::Edition2015 {
                         if !rem_targets.is_empty() {
                             let mut rem_targets_str = String::new();
                             for t in rem_targets.iter() {
@@ -694,8 +693,9 @@ https://github.com/rust-lang/cargo/issues/5330",
                             ));
                         };
                         false
+                    } else {
+                        true
                     }
-                },
             };
 
             if autodiscover {
@@ -805,7 +805,7 @@ fn target_path(
     match (first, second) {
         (Some(path), None) => Ok(path),
         (None, None) | (Some(_), Some(_)) => {
-            if edition < Edition::Edition2018 {
+            if edition == Edition::Edition2015 {
                 if let Some(path) = legacy_path(target) {
                     return Ok(path);
                 }