Skip to content

Commit 8dd9869

Browse files
committed
Auto merge of #8189 - matthiaskrgr:clippy_v12, r=ehuss
clippy fixes
2 parents ffc2923 + 6694fdb commit 8dd9869

File tree

16 files changed

+25
-25
lines changed

16 files changed

+25
-25
lines changed

crates/cargo-test-support/src/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl Package {
442442
} else {
443443
registry_path.join(&file)
444444
};
445-
let prev = fs::read_to_string(&dst).unwrap_or(String::new());
445+
let prev = fs::read_to_string(&dst).unwrap_or_default();
446446
t!(fs::create_dir_all(dst.parent().unwrap()));
447447
t!(fs::write(&dst, prev + &line[..] + "\n"));
448448

src/bin/cargo/commands/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
206206
.warn("the --no-dev-dependencies flag has changed to -e=no-dev")?;
207207
kinds.push("no-dev");
208208
}
209-
if kinds.len() == 0 {
209+
if kinds.is_empty() {
210210
kinds.extend(&["normal", "build", "dev"]);
211211
}
212212

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ fn env_args(
448448
// This means that, e.g., even if the specified --target is the
449449
// same as the host, build scripts in plugins won't get
450450
// RUSTFLAGS.
451-
if requested_kinds != &[CompileKind::Host] && kind.is_host() {
451+
if requested_kinds != [CompileKind::Host] && kind.is_host() {
452452
// This is probably a build script or plugin and we're
453453
// compiling with --target. In this scenario there are
454454
// no rustflags we can apply.

src/cargo/core/compiler/compile_kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl CompileKind {
5555
if targets.len() > 1 && !config.cli_unstable().multitarget {
5656
bail!("specifying multiple `--target` flags requires `-Zmultitarget`")
5757
}
58-
if targets.len() != 0 {
58+
if !targets.is_empty() {
5959
return Ok(targets
6060
.iter()
6161
.map(|value| Ok(CompileKind::Target(CompileTarget::new(value)?)))

src/cargo/core/compiler/standard_lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn generate_std_roots(
161161
let features = std_features.activated_features(pkg.package_id(), FeaturesFor::NormalOrDev);
162162

163163
for kind in kinds {
164-
let list = ret.entry(*kind).or_insert(Vec::new());
164+
let list = ret.entry(*kind).or_insert_with(Vec::new);
165165
list.push(interner.intern(
166166
pkg,
167167
lib,
@@ -173,7 +173,7 @@ pub fn generate_std_roots(
173173
));
174174
}
175175
}
176-
return Ok(ret);
176+
Ok(ret)
177177
}
178178

179179
fn detect_sysroot_src_path(target_data: &RustcTargetData) -> CargoResult<PathBuf> {

src/cargo/core/compiler/unit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,6 @@ impl UnitInterner {
204204
}
205205
let item = Rc::new(item.clone());
206206
me.cache.insert(item.clone());
207-
return item;
207+
item
208208
}
209209
}

src/cargo/core/compiler/unit_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ pub fn emit_serialized_unit_graph(root_units: &[Unit], unit_graph: &UnitGraph) -
113113
let stdout = std::io::stdout();
114114
let mut lock = stdout.lock();
115115
serde_json::to_writer(&mut lock, &s)?;
116-
write!(lock, "\n")?;
116+
writeln!(lock)?;
117117
Ok(())
118118
}

src/cargo/core/manifest.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl Target {
669669
.set_name(name)
670670
.set_doctest(true)
671671
.set_doc(true);
672-
return target;
672+
target
673673
}
674674

675675
pub fn bin_target(
@@ -684,7 +684,7 @@ impl Target {
684684
.set_name(name)
685685
.set_required_features(required_features)
686686
.set_doc(true);
687-
return target;
687+
target
688688
}
689689

690690
/// Builds a `Target` corresponding to the `build = "build.rs"` entry.
@@ -696,7 +696,7 @@ impl Target {
696696
.set_for_host(true)
697697
.set_benched(false)
698698
.set_tested(false);
699-
return target;
699+
target
700700
}
701701

702702
pub fn metabuild_target(name: &str) -> Target {
@@ -707,7 +707,7 @@ impl Target {
707707
.set_for_host(true)
708708
.set_benched(false)
709709
.set_tested(false);
710-
return target;
710+
target
711711
}
712712

713713
pub fn example_target(
@@ -733,7 +733,7 @@ impl Target {
733733
.set_required_features(required_features)
734734
.set_tested(false)
735735
.set_benched(false);
736-
return target;
736+
target
737737
}
738738

739739
pub fn test_target(
@@ -748,7 +748,7 @@ impl Target {
748748
.set_name(name)
749749
.set_required_features(required_features)
750750
.set_benched(false);
751-
return target;
751+
target
752752
}
753753

754754
pub fn bench_target(
@@ -763,7 +763,7 @@ impl Target {
763763
.set_name(name)
764764
.set_required_features(required_features)
765765
.set_tested(false);
766-
return target;
766+
target
767767
}
768768

769769
pub fn name(&self) -> &str {

src/cargo/core/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ fn lock(
622622

623623
// Lock the summary's ID if possible
624624
let summary = match pair {
625-
Some((precise, _)) => summary.override_id(precise.clone()),
625+
Some((precise, _)) => summary.override_id(*precise),
626626
None => summary,
627627
};
628628
summary.map_dependencies(|dep| {

src/cargo/core/resolver/conflict_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl ConflictCache {
213213

214214
for c in con.keys() {
215215
self.dep_from_pid
216-
.entry(c.clone())
216+
.entry(*c)
217217
.or_insert_with(HashSet::new)
218218
.insert(dep.clone());
219219
}

0 commit comments

Comments
 (0)