Skip to content

Commit c77f31c

Browse files
committed
Auto merge of #7484 - ehuss:clippy-fixes, r=alexcrichton
Some minor clippy fixes.
2 parents a429e8c + fba07ba commit c77f31c

File tree

8 files changed

+22
-26
lines changed

8 files changed

+22
-26
lines changed

src/cargo/core/compiler/build_config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl ProfileKind {
1818
match self {
1919
ProfileKind::Dev => "dev",
2020
ProfileKind::Release => "release",
21-
ProfileKind::Custom(name) => &name,
21+
ProfileKind::Custom(name) => name,
2222
}
2323
}
2424
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
111111
None => return true,
112112
};
113113
let name = kind.short_name(self);
114-
platform.matches(&name, self.cfg(kind))
114+
platform.matches(name, self.cfg(kind))
115115
}
116116

117117
/// Gets the user-specified linker for a particular host or target.

src/cargo/core/profiles.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl Profiles {
251251
_ => {}
252252
};
253253

254-
let mut maker = self.process_chain(name, &profile, &mut set, &mut result, profiles)?;
254+
let mut maker = self.process_chain(name, profile, &mut set, &mut result, profiles)?;
255255
result.reverse();
256256
maker.inherits = result;
257257

@@ -263,7 +263,7 @@ impl Profiles {
263263

264264
fn process_chain(
265265
&mut self,
266-
name: &String,
266+
name: &str,
267267
profile: &TomlProfile,
268268
set: &mut HashSet<String>,
269269
result: &mut Vec<TomlProfile>,
@@ -273,7 +273,7 @@ impl Profiles {
273273
match profile.inherits.as_ref().map(|x| x.as_str()) {
274274
Some(name @ "dev") | Some(name @ "release") => {
275275
// These are the root profiles
276-
return Ok(self.by_name.get(name).unwrap().clone());
276+
Ok(self.by_name.get(name).unwrap().clone())
277277
}
278278
Some(name) => {
279279
let name = name.to_owned();

src/cargo/ops/cargo_package.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,11 @@ fn check_repo_state(
292292
if let Ok(status) = repo.status_file(relative) {
293293
if status == git2::Status::CURRENT {
294294
false
295+
} else if relative.to_str().unwrap_or("") == "Cargo.lock" {
296+
// It is OK to include this file even if it is ignored.
297+
status != git2::Status::IGNORED
295298
} else {
296-
if relative.to_str().unwrap_or("") == "Cargo.lock" {
297-
// It is OK to include this file even if it is ignored.
298-
status != git2::Status::IGNORED
299-
} else {
300-
true
301-
}
299+
true
302300
}
303301
} else {
304302
submodule_dirty(file)

src/cargo/ops/cargo_test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ fn run_doc_tests(
170170
p.arg("--enable-per-target-ignores");
171171
}
172172

173-
runtool.as_ref().map(|(runtool, runtool_args)| {
173+
if let Some((runtool, runtool_args)) = runtool {
174174
p.arg("--runtool").arg(runtool);
175175
for arg in runtool_args {
176176
p.arg("--runtool-arg").arg(arg);
177177
}
178-
});
178+
}
179179

180180
for &rust_dep in &[&compilation.deps_output] {
181181
let mut arg = OsString::from("dependency=");

src/cargo/ops/common_for_install_and_uninstall.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl InstallInfo {
527527
self.features == feature_set(&opts.features)
528528
&& self.all_features == opts.all_features
529529
&& self.no_default_features == opts.no_default_features
530-
&& self.profile == opts.build_config.profile_name().to_string()
530+
&& self.profile == opts.build_config.profile_name()
531531
&& (self.target.is_none() || self.target.as_ref().map(|t| t.as_ref()) == Some(target))
532532
&& &self.bins == exes
533533
}

src/cargo/util/command_prelude.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,8 @@ pub trait ArgMatchesExt {
313313
match profile_checking {
314314
ProfileChecking::Unchecked => {}
315315
ProfileChecking::Checked => {
316-
if specified_profile.is_some() {
317-
if !config.cli_unstable().unstable_options {
318-
failure::bail!("Usage of `--profile` requires `-Z unstable-options`")
319-
}
316+
if specified_profile.is_some() && !config.cli_unstable().unstable_options {
317+
failure::bail!("Usage of `--profile` requires `-Z unstable-options`")
320318
}
321319
}
322320
}

src/cargo/util/toml/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl TomlProfiles {
287287
warnings.push("use `[profile.dev]` to configure debug builds".to_string());
288288
}
289289

290-
profile.validate(&name, features, warnings)?;
290+
profile.validate(name, features, warnings)?;
291291
}
292292
Ok(())
293293
}
@@ -490,15 +490,15 @@ impl TomlProfile {
490490
match &self.dir_name {
491491
None => {}
492492
Some(dir_name) => {
493-
Self::validate_name(&dir_name, "dir-name")?;
493+
Self::validate_name(dir_name, "dir-name")?;
494494
}
495495
}
496496

497497
// `inherits` validation
498498
match &self.inherits {
499499
None => {}
500500
Some(inherits) => {
501-
Self::validate_name(&inherits, "inherits")?;
501+
Self::validate_name(inherits, "inherits")?;
502502
}
503503
}
504504

@@ -581,31 +581,31 @@ impl TomlProfile {
581581
}
582582

583583
if let Some(v) = profile.codegen_units {
584-
self.codegen_units = Some(v.clone());
584+
self.codegen_units = Some(v);
585585
}
586586

587587
if let Some(v) = &profile.debug {
588588
self.debug = Some(v.clone());
589589
}
590590

591591
if let Some(v) = profile.debug_assertions {
592-
self.debug_assertions = Some(v.clone());
592+
self.debug_assertions = Some(v);
593593
}
594594

595595
if let Some(v) = profile.rpath {
596-
self.rpath = Some(v.clone());
596+
self.rpath = Some(v);
597597
}
598598

599599
if let Some(v) = &profile.panic {
600600
self.panic = Some(v.clone());
601601
}
602602

603603
if let Some(v) = profile.overflow_checks {
604-
self.overflow_checks = Some(v.clone());
604+
self.overflow_checks = Some(v);
605605
}
606606

607607
if let Some(v) = profile.incremental {
608-
self.incremental = Some(v.clone());
608+
self.incremental = Some(v);
609609
}
610610

611611
if let Some(v) = &profile.overrides {

0 commit comments

Comments
 (0)