Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
pub fn get_version_string(is_verbose: bool) -> String {
let version = cargo::version();
let mut version_string = version.to_string();
version_string.push_str("\n");
version_string.push('\n');
if is_verbose {
version_string.push_str(&format!(
"release: {}.{}.{}\n",
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
let mut queue = JobQueue::new(self.bcx);
let mut plan = BuildPlan::new();
let build_plan = self.bcx.build_config.build_plan;
self.lto = super::lto::generate(&self.bcx)?;
self.lto = super::lto::generate(self.bcx)?;
self.prepare_units()?;
self.prepare()?;
custom_build::build_map(&mut self)?;
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
let output = cmd
.exec_with_streaming(
&mut |stdout| {
if stdout.starts_with(CARGO_WARNING) {
warnings_in_case_of_panic.push(stdout[CARGO_WARNING.len()..].to_owned());
if let Some(warning) = stdout.strip_prefix(CARGO_WARNING) {
warnings_in_case_of_panic.push(warning.to_owned());
}
if extra_verbose {
state.stdout(format!("{}{}", prefix, stdout));
Expand Down
4 changes: 1 addition & 3 deletions src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1975,9 +1975,7 @@ pub fn parse_rustc_dep_info(rustc_dep_info: &Path) -> CargoResult<RustcDepInfo>
let mut found_deps = false;

for line in contents.lines() {
let env_dep_prefix = "# env-dep:";
if line.starts_with(env_dep_prefix) {
let rest = &line[env_dep_prefix.len()..];
if let Some(rest) = line.strip_prefix("# env-dep:") {
let mut parts = rest.splitn(2, '=');
let env_var = match parts.next() {
Some(s) => s,
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub(super) fn activation_error(
));
}

msg.push_str("\n");
msg.push('\n');
}
msg.push_str("required by ");
msg.push_str(&describe_path(
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/common_for_install_and_uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl InstallTracker {
if let Some(p) = p.as_ref() {
msg.push_str(&format!(" as part of `{}`\n", p));
} else {
msg.push_str("\n");
msg.push('\n');
}
}
msg.push_str("Add --force to overwrite");
Expand Down
5 changes: 2 additions & 3 deletions src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,8 @@ impl FixArgs {
continue;
}
if let Some(s) = path.to_str() {
let prefix = "--edition=";
if s.starts_with(prefix) {
ret.enabled_edition = Some(s[prefix.len()..].to_string());
if let Some(edition) = s.strip_prefix("--edition=") {
ret.enabled_edition = Some(edition.to_string());
continue;
}
if s.starts_with("--error-format=") || s.starts_with("--json=") {
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String {
for entry in list {
out.push_str("[[patch.unused]]\n");
emit_package(entry.as_table().unwrap(), &mut out);
out.push_str("\n");
out.push('\n');
}
}

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

out.push_str("]\n");
}
out.push_str("\n");
out.push('\n');
} else if dep.contains_key("replace") {
out.push_str(&format!("replace = {}\n\n", &dep["replace"]));
}
Expand Down
8 changes: 2 additions & 6 deletions src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ where
msg.push_str(attempt);
}
}
msg.push_str("\n");
msg.push('\n');
if !ssh_agent_attempts.is_empty() {
let names = ssh_agent_attempts
.iter()
Expand Down Expand Up @@ -1154,11 +1154,7 @@ fn github_up_to_date(

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

let url = format!(
"https://api.github.com/repos/{}/{}/commits/{}",
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/config/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl ConfigKey {

fn _push(&mut self, env: &str, config: &str) {
self.parts.push((config.to_string(), self.env.len()));
self.env.push_str("_");
self.env.push('_');
self.env.push_str(env);
}

Expand Down
10 changes: 5 additions & 5 deletions src/cargo/util/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,20 @@ impl Format {
// Draw the `===>`
if hashes > 0 {
for _ in 0..hashes - 1 {
string.push_str("=");
string.push('=');
}
if cur == max {
string.push_str("=");
string.push('=');
} else {
string.push_str(">");
string.push('>');
}
}

// Draw the empty space we have left to do
for _ in 0..(display_width - hashes) {
string.push_str(" ");
string.push(' ');
}
string.push_str("]");
string.push(']');
string.push_str(&stats);

Some(string)
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ impl DetailedTomlDependency {
.map(GitReference::Branch)
.or_else(|| self.tag.clone().map(GitReference::Tag))
.or_else(|| self.rev.clone().map(GitReference::Rev))
.unwrap_or_else(|| GitReference::DefaultBranch);
.unwrap_or(GitReference::DefaultBranch);
let loc = git.into_url()?;

if let Some(fragment) = loc.fragment() {
Expand Down