Skip to content

Commit d554133

Browse files
committed
Some minor clippy fixes.
1 parent 6a38927 commit d554133

File tree

12 files changed

+20
-27
lines changed

12 files changed

+20
-27
lines changed

src/bin/cargo/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
118118
pub fn get_version_string(is_verbose: bool) -> String {
119119
let version = cargo::version();
120120
let mut version_string = version.to_string();
121-
version_string.push_str("\n");
121+
version_string.push('\n');
122122
if is_verbose {
123123
version_string.push_str(&format!(
124124
"release: {}.{}.{}\n",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
126126
let mut queue = JobQueue::new(self.bcx);
127127
let mut plan = BuildPlan::new();
128128
let build_plan = self.bcx.build_config.build_plan;
129-
self.lto = super::lto::generate(&self.bcx)?;
129+
self.lto = super::lto::generate(self.bcx)?;
130130
self.prepare_units()?;
131131
self.prepare()?;
132132
custom_build::build_map(&mut self)?;

src/cargo/core/compiler/custom_build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
349349
let output = cmd
350350
.exec_with_streaming(
351351
&mut |stdout| {
352-
if stdout.starts_with(CARGO_WARNING) {
353-
warnings_in_case_of_panic.push(stdout[CARGO_WARNING.len()..].to_owned());
352+
if let Some(warning) = stdout.strip_prefix(CARGO_WARNING) {
353+
warnings_in_case_of_panic.push(warning.to_owned());
354354
}
355355
if extra_verbose {
356356
state.stdout(format!("{}{}", prefix, stdout));

src/cargo/core/compiler/fingerprint.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,9 +1975,7 @@ pub fn parse_rustc_dep_info(rustc_dep_info: &Path) -> CargoResult<RustcDepInfo>
19751975
let mut found_deps = false;
19761976

19771977
for line in contents.lines() {
1978-
let env_dep_prefix = "# env-dep:";
1979-
if line.starts_with(env_dep_prefix) {
1980-
let rest = &line[env_dep_prefix.len()..];
1978+
if let Some(rest) = line.strip_prefix("# env-dep:") {
19811979
let mut parts = rest.splitn(2, '=');
19821980
let env_var = match parts.next() {
19831981
Some(s) => s,

src/cargo/core/resolver/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ pub(super) fn activation_error(
302302
));
303303
}
304304

305-
msg.push_str("\n");
305+
msg.push('\n');
306306
}
307307
msg.push_str("required by ");
308308
msg.push_str(&describe_path(

src/cargo/ops/common_for_install_and_uninstall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl InstallTracker {
230230
if let Some(p) = p.as_ref() {
231231
msg.push_str(&format!(" as part of `{}`\n", p));
232232
} else {
233-
msg.push_str("\n");
233+
msg.push('\n');
234234
}
235235
}
236236
msg.push_str("Add --force to overwrite");

src/cargo/ops/fix.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,8 @@ impl FixArgs {
614614
continue;
615615
}
616616
if let Some(s) = path.to_str() {
617-
let prefix = "--edition=";
618-
if s.starts_with(prefix) {
619-
ret.enabled_edition = Some(s[prefix.len()..].to_string());
617+
if let Some(edition) = s.strip_prefix("--edition=") {
618+
ret.enabled_edition = Some(edition.to_string());
620619
continue;
621620
}
622621
if s.starts_with("--error-format=") || s.starts_with("--json=") {

src/cargo/ops/lockfile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String {
151151
for entry in list {
152152
out.push_str("[[patch.unused]]\n");
153153
emit_package(entry.as_table().unwrap(), &mut out);
154-
out.push_str("\n");
154+
out.push('\n');
155155
}
156156
}
157157

@@ -214,7 +214,7 @@ fn emit_package(dep: &toml::value::Table, out: &mut String) {
214214

215215
out.push_str("]\n");
216216
}
217-
out.push_str("\n");
217+
out.push('\n');
218218
} else if dep.contains_key("replace") {
219219
out.push_str(&format!("replace = {}\n\n", &dep["replace"]));
220220
}

src/cargo/sources/git/utils.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ where
755755
msg.push_str(attempt);
756756
}
757757
}
758-
msg.push_str("\n");
758+
msg.push('\n');
759759
if !ssh_agent_attempts.is_empty() {
760760
let names = ssh_agent_attempts
761761
.iter()
@@ -1154,11 +1154,7 @@ fn github_up_to_date(
11541154

11551155
// Trim off the `.git` from the repository, if present, since that's
11561156
// optional for GitHub and won't work when we try to use the API as well.
1157-
let repository = if repository.ends_with(".git") {
1158-
&repository[..repository.len() - 4]
1159-
} else {
1160-
repository
1161-
};
1157+
let repository = repository.strip_suffix(".git").unwrap_or(repository);
11621158

11631159
let url = format!(
11641160
"https://api.github.com/repos/{}/{}/commits/{}",

src/cargo/util/config/key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl ConfigKey {
6666

6767
fn _push(&mut self, env: &str, config: &str) {
6868
self.parts.push((config.to_string(), self.env.len()));
69-
self.env.push_str("_");
69+
self.env.push('_');
7070
self.env.push_str(env);
7171
}
7272

src/cargo/util/progress.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,20 @@ impl Format {
266266
// Draw the `===>`
267267
if hashes > 0 {
268268
for _ in 0..hashes - 1 {
269-
string.push_str("=");
269+
string.push('=');
270270
}
271271
if cur == max {
272-
string.push_str("=");
272+
string.push('=');
273273
} else {
274-
string.push_str(">");
274+
string.push('>');
275275
}
276276
}
277277

278278
// Draw the empty space we have left to do
279279
for _ in 0..(display_width - hashes) {
280-
string.push_str(" ");
280+
string.push(' ');
281281
}
282-
string.push_str("]");
282+
string.push(']');
283283
string.push_str(&stats);
284284

285285
Some(string)

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ impl DetailedTomlDependency {
16901690
.map(GitReference::Branch)
16911691
.or_else(|| self.tag.clone().map(GitReference::Tag))
16921692
.or_else(|| self.rev.clone().map(GitReference::Rev))
1693-
.unwrap_or_else(|| GitReference::DefaultBranch);
1693+
.unwrap_or(GitReference::DefaultBranch);
16941694
let loc = git.into_url()?;
16951695

16961696
if let Some(fragment) = loc.fragment() {

0 commit comments

Comments
 (0)