Skip to content

Commit 02205f5

Browse files
committed
Auto merge of #8324 - matthiaskrgr:clippy_v14, r=ehuss
fix clippy warnings
2 parents 0227f04 + 6eefe3c commit 02205f5

File tree

12 files changed

+20
-25
lines changed

12 files changed

+20
-25
lines changed

crates/cargo-platform/src/error.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct ParseError {
66
orig: String,
77
}
88

9+
#[non_exhaustive]
910
#[derive(Debug)]
1011
pub enum ParseErrorKind {
1112
UnterminatedString,
@@ -17,9 +18,6 @@ pub enum ParseErrorKind {
1718
IncompleteExpr(&'static str),
1819
UnterminatedExpression(String),
1920
InvalidTarget(String),
20-
21-
#[doc(hidden)]
22-
__Nonexhaustive,
2321
}
2422

2523
impl fmt::Display for ParseError {
@@ -53,7 +51,6 @@ impl fmt::Display for ParseErrorKind {
5351
write!(f, "unexpected content `{}` found after cfg expression", s)
5452
}
5553
InvalidTarget(s) => write!(f, "invalid target specifier: {}", s),
56-
__Nonexhaustive => unreachable!(),
5754
}
5855
}
5956
}

src/cargo/core/compiler/fingerprint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ impl Fingerprint {
894894
if a.name != b.name {
895895
let e = format_err!("`{}` != `{}`", a.name, b.name)
896896
.context("unit dependency name changed");
897-
return Err(e.into());
897+
return Err(e);
898898
}
899899

900900
if a.fingerprint.hash() != b.fingerprint.hash() {
@@ -906,7 +906,7 @@ impl Fingerprint {
906906
b.fingerprint.hash()
907907
)
908908
.context("unit dependency information changed");
909-
return Err(e.into());
909+
return Err(e);
910910
}
911911
}
912912

src/cargo/core/compiler/rustdoc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn add_root_urls(
7979
return Ok(());
8080
}
8181
let map = config.doc_extern_map()?;
82-
if map.registries.len() == 0 && map.std.is_none() {
82+
if map.registries.is_empty() && map.std.is_none() {
8383
// Skip doing unnecessary work.
8484
return Ok(());
8585
}
@@ -90,13 +90,13 @@ pub fn add_root_urls(
9090
.keys()
9191
.filter_map(|name| {
9292
if let Ok(index_url) = config.get_registry_index(name) {
93-
return Some((name, index_url));
93+
Some((name, index_url))
9494
} else {
9595
log::warn!(
9696
"`doc.extern-map.{}` specifies a registry that is not defined",
9797
name
9898
);
99-
return None;
99+
None
100100
}
101101
})
102102
.collect();

src/cargo/core/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl<'cfg> PackageRegistry<'cfg> {
294294
.expect("loaded source not present");
295295
let summaries = source.query_vec(dep)?;
296296
let (summary, should_unlock) =
297-
summary_for_patch(orig_patch, &locked, summaries, source).chain_err(|| {
297+
summary_for_patch(orig_patch, locked, summaries, source).chain_err(|| {
298298
format!(
299299
"patch for `{}` in `{}` failed to resolve",
300300
orig_patch.package_name(),

src/cargo/core/workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ impl<'cfg> Workspace<'cfg> {
863863
let err = anyhow::format_err!("{}", warning.message);
864864
let cx =
865865
anyhow::format_err!("failed to parse manifest at `{}`", path.display());
866-
return Err(err.context(cx).into());
866+
return Err(err.context(cx));
867867
} else {
868868
let msg = if self.root_manifest.is_none() {
869869
warning.message.to_string()

src/cargo/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#![allow(clippy::unneeded_field_pattern)]
2929
// false positives in target-specific code, for details see
3030
// https://github.com/rust-lang/cargo/pull/7251#pullrequestreview-274914270
31-
#![allow(clippy::identity_conversion)]
31+
#![allow(clippy::useless_conversion)]
3232

3333
use crate::core::shell::Verbosity::Verbose;
3434
use crate::core::Shell;

src/cargo/ops/cargo_install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ where
570570
// best-effort check to see if we can avoid hitting the network.
571571
if let Ok(pkg) = select_dep_pkg(source, dep, config, false) {
572572
let (_ws, rustc, target) =
573-
make_ws_rustc_target(&config, opts, &source.source_id(), pkg.clone())?;
574-
if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, &dst, force) {
573+
make_ws_rustc_target(config, opts, &source.source_id(), pkg.clone())?;
574+
if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, dst, force) {
575575
return Ok(Some(pkg));
576576
}
577577
}

src/cargo/ops/cargo_read_manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn walk(path: &Path, callback: &mut dyn FnMut(&Path) -> CargoResult<bool>) -> Ca
112112
Err(e) => {
113113
let cx = format!("failed to read directory `{}`", path.display());
114114
let e = anyhow::Error::from(e);
115-
return Err(e.context(cx).into());
115+
return Err(e.context(cx));
116116
}
117117
};
118118
for dir in dirs {

src/cargo/util/flock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn acquire(
307307
if !error_contended(&e) {
308308
let e = anyhow::Error::from(e);
309309
let cx = format!("failed to lock file: {}", path.display());
310-
return Err(e.context(cx).into());
310+
return Err(e.context(cx));
311311
}
312312
}
313313
}

src/cargo/util/process_builder.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,11 @@ mod imp {
381381
pub fn exec_replace(process_builder: &ProcessBuilder) -> CargoResult<()> {
382382
let mut command = process_builder.build_command();
383383
let error = command.exec();
384-
Err(anyhow::Error::from(error)
385-
.context(process_error(
386-
&format!("could not execute process {}", process_builder),
387-
None,
388-
None,
389-
))
390-
.into())
384+
Err(anyhow::Error::from(error).context(process_error(
385+
&format!("could not execute process {}", process_builder),
386+
None,
387+
None,
388+
)))
391389
}
392390
}
393391

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ and this will become a hard error in the future.",
163163
}
164164

165165
let first_error = anyhow::Error::from(first_error);
166-
Err(first_error.context("could not parse input as TOML").into())
166+
Err(first_error.context("could not parse input as TOML"))
167167
}
168168

169169
type TomlLibTarget = TomlTarget;

tests/testsuite/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![allow(clippy::blacklisted_name)]
44
#![allow(clippy::explicit_iter_loop)]
55
#![allow(clippy::redundant_closure)]
6-
#![allow(clippy::block_in_if_condition_stmt)] // clippy doesn't agree with rustfmt 😂
6+
#![allow(clippy::blocks_in_if_conditions)] // clippy doesn't agree with rustfmt 😂
77
#![allow(clippy::inefficient_to_string)] // this causes suggestions that result in `(*s).to_string()`
88
#![warn(clippy::needless_borrow)]
99
#![warn(clippy::redundant_clone)]

0 commit comments

Comments
 (0)