]> git.proxmox.com Git - cargo.git/commitdiff
fix clippy warnings
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 3 Jun 2020 22:44:59 +0000 (00:44 +0200)
committerMatthias Krüger <matthias.krueger@famsik.de>
Wed, 3 Jun 2020 22:55:45 +0000 (00:55 +0200)
12 files changed:
crates/cargo-platform/src/error.rs
src/cargo/core/compiler/fingerprint.rs
src/cargo/core/compiler/rustdoc.rs
src/cargo/core/registry.rs
src/cargo/core/workspace.rs
src/cargo/lib.rs
src/cargo/ops/cargo_install.rs
src/cargo/ops/cargo_read_manifest.rs
src/cargo/util/flock.rs
src/cargo/util/process_builder.rs
src/cargo/util/toml/mod.rs
tests/testsuite/main.rs

index 19a15a1e132150bc79ceaad5611a38c45b812402..bf4b35f271dce00ecdee87ae8b7275d30ff3e52a 100644 (file)
@@ -6,6 +6,7 @@ pub struct ParseError {
     orig: String,
 }
 
+#[non_exhaustive]
 #[derive(Debug)]
 pub enum ParseErrorKind {
     UnterminatedString,
@@ -17,9 +18,6 @@ pub enum ParseErrorKind {
     IncompleteExpr(&'static str),
     UnterminatedExpression(String),
     InvalidTarget(String),
-
-    #[doc(hidden)]
-    __Nonexhaustive,
 }
 
 impl fmt::Display for ParseError {
@@ -53,7 +51,6 @@ impl fmt::Display for ParseErrorKind {
                 write!(f, "unexpected content `{}` found after cfg expression", s)
             }
             InvalidTarget(s) => write!(f, "invalid target specifier: {}", s),
-            __Nonexhaustive => unreachable!(),
         }
     }
 }
index 4e554202ec02d992c3d473b74fe182f498ed5d04..4adab7efbcfbc961d77d7411aa2f7e4a5cf3b173 100644 (file)
@@ -894,7 +894,7 @@ impl Fingerprint {
             if a.name != b.name {
                 let e = format_err!("`{}` != `{}`", a.name, b.name)
                     .context("unit dependency name changed");
-                return Err(e.into());
+                return Err(e);
             }
 
             if a.fingerprint.hash() != b.fingerprint.hash() {
@@ -906,7 +906,7 @@ impl Fingerprint {
                     b.fingerprint.hash()
                 )
                 .context("unit dependency information changed");
-                return Err(e.into());
+                return Err(e);
             }
         }
 
index ad0524a2fbc81758c4fd7b93a33c7e705d13e8a4..d32f2d6912f30dc930fb15a13362a81045864d56 100644 (file)
@@ -79,7 +79,7 @@ pub fn add_root_urls(
         return Ok(());
     }
     let map = config.doc_extern_map()?;
-    if map.registries.len() == 0 && map.std.is_none() {
+    if map.registries.is_empty() && map.std.is_none() {
         // Skip doing unnecessary work.
         return Ok(());
     }
@@ -90,13 +90,13 @@ pub fn add_root_urls(
         .keys()
         .filter_map(|name| {
             if let Ok(index_url) = config.get_registry_index(name) {
-                return Some((name, index_url));
+                Some((name, index_url))
             } else {
                 log::warn!(
                     "`doc.extern-map.{}` specifies a registry that is not defined",
                     name
                 );
-                return None;
+                None
             }
         })
         .collect();
index 2f63c26203a28990547910e5dbd10894d27c9824..160ca770ad71f0cea6f320d1a4a1a9ab95d72e60 100644 (file)
@@ -294,7 +294,7 @@ impl<'cfg> PackageRegistry<'cfg> {
                     .expect("loaded source not present");
                 let summaries = source.query_vec(dep)?;
                 let (summary, should_unlock) =
-                    summary_for_patch(orig_patch, &locked, summaries, source).chain_err(|| {
+                    summary_for_patch(orig_patch, locked, summaries, source).chain_err(|| {
                         format!(
                             "patch for `{}` in `{}` failed to resolve",
                             orig_patch.package_name(),
index 5931a9a5c7f1aa28f3edc6cfc63e6070dcb687c5..aec08c79e3a925d02179dcec164bb59002642e26 100644 (file)
@@ -863,7 +863,7 @@ impl<'cfg> Workspace<'cfg> {
                     let err = anyhow::format_err!("{}", warning.message);
                     let cx =
                         anyhow::format_err!("failed to parse manifest at `{}`", path.display());
-                    return Err(err.context(cx).into());
+                    return Err(err.context(cx));
                 } else {
                     let msg = if self.root_manifest.is_none() {
                         warning.message.to_string()
index 19cbd49c1011a4a7cbad7f2b45ab8df2a4d41781..29eb110884c975018191306728eb94426b512892 100644 (file)
@@ -28,7 +28,7 @@
 #![allow(clippy::unneeded_field_pattern)]
 // false positives in target-specific code, for details see
 // https://github.com/rust-lang/cargo/pull/7251#pullrequestreview-274914270
-#![allow(clippy::identity_conversion)]
+#![allow(clippy::useless_conversion)]
 
 use crate::core::shell::Verbosity::Verbose;
 use crate::core::Shell;
index 9b1b08a7254378db626633105605a6174ac8d10d..1c7f5df998537398db049eb34bed2b70652528f4 100644 (file)
@@ -570,8 +570,8 @@ where
     // best-effort check to see if we can avoid hitting the network.
     if let Ok(pkg) = select_dep_pkg(source, dep, config, false) {
         let (_ws, rustc, target) =
-            make_ws_rustc_target(&config, opts, &source.source_id(), pkg.clone())?;
-        if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, &dst, force) {
+            make_ws_rustc_target(config, opts, &source.source_id(), pkg.clone())?;
+        if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, dst, force) {
             return Ok(Some(pkg));
         }
     }
index df1083fc30e97a23259445baac4f4bf0bd1bf32b..95975c8c153ba4cf96819cf9498a19422f3ac8cb 100644 (file)
@@ -112,7 +112,7 @@ fn walk(path: &Path, callback: &mut dyn FnMut(&Path) -> CargoResult<bool>) -> Ca
         Err(e) => {
             let cx = format!("failed to read directory `{}`", path.display());
             let e = anyhow::Error::from(e);
-            return Err(e.context(cx).into());
+            return Err(e.context(cx));
         }
     };
     for dir in dirs {
index 2d732bb7ae3980150cf7959d8a0e7cd55f3e502e..985ef6e24e055ed11fc41be9d331fc3d73325fca 100644 (file)
@@ -307,7 +307,7 @@ fn acquire(
             if !error_contended(&e) {
                 let e = anyhow::Error::from(e);
                 let cx = format!("failed to lock file: {}", path.display());
-                return Err(e.context(cx).into());
+                return Err(e.context(cx));
             }
         }
     }
index 953f8ae58af0ccece9167d78a3f6f5675439fc84..f230398140275038d13bbb1ca60107018c8b9a37 100644 (file)
@@ -381,13 +381,11 @@ mod imp {
     pub fn exec_replace(process_builder: &ProcessBuilder) -> CargoResult<()> {
         let mut command = process_builder.build_command();
         let error = command.exec();
-        Err(anyhow::Error::from(error)
-            .context(process_error(
-                &format!("could not execute process {}", process_builder),
-                None,
-                None,
-            ))
-            .into())
+        Err(anyhow::Error::from(error).context(process_error(
+            &format!("could not execute process {}", process_builder),
+            None,
+            None,
+        )))
     }
 }
 
index b1688b857445272609d96f7eb0bcf80ff382edc7..d39d093560064608f95de568b5af8363d29a5dec 100644 (file)
@@ -163,7 +163,7 @@ and this will become a hard error in the future.",
     }
 
     let first_error = anyhow::Error::from(first_error);
-    Err(first_error.context("could not parse input as TOML").into())
+    Err(first_error.context("could not parse input as TOML"))
 }
 
 type TomlLibTarget = TomlTarget;
index 7aec3227b409665aedf8b48fcd02b950baae23b6..56c00c7a3f98c50d65a42b8ced64748c026fb9b9 100644 (file)
@@ -3,7 +3,7 @@
 #![allow(clippy::blacklisted_name)]
 #![allow(clippy::explicit_iter_loop)]
 #![allow(clippy::redundant_closure)]
-#![allow(clippy::block_in_if_condition_stmt)] // clippy doesn't agree with rustfmt 😂
+#![allow(clippy::blocks_in_if_conditions)] // clippy doesn't agree with rustfmt 😂
 #![allow(clippy::inefficient_to_string)] // this causes suggestions that result in `(*s).to_string()`
 #![warn(clippy::needless_borrow)]
 #![warn(clippy::redundant_clone)]