mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Fix clippy errors in cargo v1.73.0 (#1439)
It actually improves the quality of our code! Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
af04e45b5a
commit
ceba74870e
5 changed files with 14 additions and 11 deletions
|
@ -16,7 +16,7 @@ impl ExtractedFilesEntry {
|
||||||
ExtractedFilesEntry::Dir(Box::new(
|
ExtractedFilesEntry::Dir(Box::new(
|
||||||
file_name
|
file_name
|
||||||
.map(|file_name| HashSet::from([file_name.into()]))
|
.map(|file_name| HashSet::from([file_name.into()]))
|
||||||
.unwrap_or_else(HashSet::default),
|
.unwrap_or_default(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,13 +201,13 @@ fn check_filename_and_normalize(filename: &ZipString) -> Result<(PathBuf, bool),
|
||||||
.unwrap_or_else(|_| String::from_utf8_lossy(filename.as_bytes()));
|
.unwrap_or_else(|_| String::from_utf8_lossy(filename.as_bytes()));
|
||||||
|
|
||||||
let bail = |filename: Cow<'_, str>| {
|
let bail = |filename: Cow<'_, str>| {
|
||||||
Err(ZipError(ZipErrorInner::InvalidFilePath(
|
Err(DownloadError::from(ZipError(
|
||||||
filename.into_owned().into(),
|
ZipErrorInner::InvalidFilePath(filename.into_owned().into()),
|
||||||
)))
|
)))
|
||||||
};
|
};
|
||||||
|
|
||||||
if filename.contains('\0') {
|
if filename.contains('\0') {
|
||||||
return bail(filename)?;
|
return bail(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut path = PathBuf::new();
|
let mut path = PathBuf::new();
|
||||||
|
@ -216,13 +216,13 @@ fn check_filename_and_normalize(filename: &ZipString) -> Result<(PathBuf, bool),
|
||||||
// `normalize_path::NormalizePath::normalize`.
|
// `normalize_path::NormalizePath::normalize`.
|
||||||
for component in Path::new(&*filename).components() {
|
for component in Path::new(&*filename).components() {
|
||||||
match component {
|
match component {
|
||||||
Component::Prefix(_) | Component::RootDir => return bail(filename)?,
|
Component::Prefix(_) | Component::RootDir => return bail(filename),
|
||||||
Component::CurDir => (),
|
Component::CurDir => (),
|
||||||
Component::ParentDir => {
|
Component::ParentDir => {
|
||||||
if !path.pop() {
|
if !path.pop() {
|
||||||
// `PathBuf::pop` returns false if there is no parent.
|
// `PathBuf::pop` returns false if there is no parent.
|
||||||
// which means the path is invalid.
|
// which means the path is invalid.
|
||||||
return bail(filename)?;
|
return bail(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component::Normal(c) => path.push(c),
|
Component::Normal(c) => path.push(c),
|
||||||
|
|
|
@ -3,10 +3,13 @@ use std::{net::SocketAddr, sync::Arc};
|
||||||
use hyper::client::connect::dns::Name;
|
use hyper::client::connect::dns::Name;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use reqwest::dns::{Addrs, Resolve};
|
use reqwest::dns::{Addrs, Resolve};
|
||||||
use tracing::{debug, info, instrument, trace, warn};
|
use tracing::{info, instrument, warn};
|
||||||
|
use trust_dns_resolver::TokioAsyncResolver;
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
use tracing::{debug, trace};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use trust_dns_resolver::config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts};
|
use trust_dns_resolver::config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts};
|
||||||
use trust_dns_resolver::TokioAsyncResolver;
|
|
||||||
|
|
||||||
type BoxError = Box<dyn std::error::Error + Send + Sync>;
|
type BoxError = Box<dyn std::error::Error + Send + Sync>;
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ impl RepositoryHost {
|
||||||
match repo.domain() {
|
match repo.domain() {
|
||||||
Some(domain) if domain.starts_with("github") => GitHub,
|
Some(domain) if domain.starts_with("github") => GitHub,
|
||||||
Some(domain) if domain.starts_with("gitlab") => GitLab,
|
Some(domain) if domain.starts_with("gitlab") => GitLab,
|
||||||
Some(domain) if domain == "bitbucket.org" => BitBucket,
|
Some("bitbucket.org") => BitBucket,
|
||||||
Some(domain) if domain == "sourceforge.net" => SourceForge,
|
Some("sourceforge.net") => SourceForge,
|
||||||
_ => Unknown,
|
_ => Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl Eq for CrateInfo {}
|
||||||
|
|
||||||
impl PartialOrd for CrateInfo {
|
impl PartialOrd for CrateInfo {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
||||||
self.name.partial_cmp(&other.name)
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue