Skip to content

Commit

Permalink
style: Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed May 29, 2024
1 parent 8a97552 commit d48cbc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
15 changes: 5 additions & 10 deletions src/bin/upgrade/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ fn exec(args: UpgradeArgs) -> CargoResult<()> {
}
}
}
let latest_compatible = semver::VersionReq::parse(&old_version_req)
let latest_compatible = VersionReq::parse(&old_version_req)
.ok()
.and_then(|old_version_req| {
get_compatible_dependency(
Expand Down Expand Up @@ -482,7 +482,7 @@ fn exec(args: UpgradeArgs) -> CargoResult<()> {
.iter()
.filter_map(|(name, req)| {
req.as_ref()
.and_then(|req| semver::VersionReq::parse(req).ok())
.and_then(|req| VersionReq::parse(req).ok())
.and_then(|req| {
let precise = precise_version(&req)?;
Some((name, (req, precise)))
Expand Down Expand Up @@ -709,12 +709,7 @@ fn precise_version(version_req: &VersionReq) -> Option<String> {
matches!(
c.op,
// Only ops we can determine a precise version from
semver::Op::Exact
| semver::Op::GreaterEq
| semver::Op::LessEq
| semver::Op::Tilde
| semver::Op::Caret
| semver::Op::Wildcard
Op::Exact | Op::GreaterEq | Op::LessEq | Op::Tilde | Op::Caret | Op::Wildcard
)
})
.filter_map(|c| {
Expand Down Expand Up @@ -794,7 +789,7 @@ impl Dep {
.and_then(|v| semver::Version::parse(v).ok())
{
if let Some(new_version_req) = &self.new_version_req {
if let Ok(new_version_req) = semver::VersionReq::parse(new_version_req) {
if let Ok(new_version_req) = VersionReq::parse(new_version_req) {
if !new_version_req.matches(&latest_version) {
spec.set_fg(Some(Color::Red));
}
Expand Down Expand Up @@ -853,7 +848,7 @@ impl Dep {
.and_then(|v| semver::Version::parse(v).ok())
{
if let Some(old_version_req) = &self.old_version_req {
if let Ok(old_version_req) = semver::VersionReq::parse(old_version_req) {
if let Ok(old_version_req) = VersionReq::parse(old_version_req) {
return old_version_req.matches(&latest_version);
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ impl LocalManifest {
if !path.is_absolute() {
anyhow::bail!("can only edit absolute paths, got {}", path.display());
}
let data =
std::fs::read_to_string(path).with_context(|| "Failed to read manifest contents")?;
let data = fs::read_to_string(path).with_context(|| "Failed to read manifest contents")?;
let manifest = data.parse().context("Unable to parse Cargo.toml")?;
Ok(LocalManifest {
manifest,
Expand All @@ -232,7 +231,7 @@ impl LocalManifest {
let s = self.manifest.data.to_string();
let new_contents_bytes = s.as_bytes();

std::fs::write(&self.path, new_contents_bytes).context("Failed to write updated Cargo.toml")
fs::write(&self.path, new_contents_bytes).context("Failed to write updated Cargo.toml")
}

/// Remove entry from a Cargo.toml.
Expand Down

0 comments on commit d48cbc1

Please sign in to comment.