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:
Jiahao XU 2023-10-06 22:10:42 +10:00 committed by GitHub
parent af04e45b5a
commit ceba74870e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 11 deletions

View file

@ -16,7 +16,7 @@ impl ExtractedFilesEntry {
ExtractedFilesEntry::Dir(Box::new(
file_name
.map(|file_name| HashSet::from([file_name.into()]))
.unwrap_or_else(HashSet::default),
.unwrap_or_default(),
))
}
}

View file

@ -201,13 +201,13 @@ fn check_filename_and_normalize(filename: &ZipString) -> Result<(PathBuf, bool),
.unwrap_or_else(|_| String::from_utf8_lossy(filename.as_bytes()));
let bail = |filename: Cow<'_, str>| {
Err(ZipError(ZipErrorInner::InvalidFilePath(
filename.into_owned().into(),
Err(DownloadError::from(ZipError(
ZipErrorInner::InvalidFilePath(filename.into_owned().into()),
)))
};
if filename.contains('\0') {
return bail(filename)?;
return bail(filename);
}
let mut path = PathBuf::new();
@ -216,13 +216,13 @@ fn check_filename_and_normalize(filename: &ZipString) -> Result<(PathBuf, bool),
// `normalize_path::NormalizePath::normalize`.
for component in Path::new(&*filename).components() {
match component {
Component::Prefix(_) | Component::RootDir => return bail(filename)?,
Component::Prefix(_) | Component::RootDir => return bail(filename),
Component::CurDir => (),
Component::ParentDir => {
if !path.pop() {
// `PathBuf::pop` returns false if there is no parent.
// which means the path is invalid.
return bail(filename)?;
return bail(filename);
}
}
Component::Normal(c) => path.push(c),

View file

@ -3,10 +3,13 @@ use std::{net::SocketAddr, sync::Arc};
use hyper::client::connect::dns::Name;
use once_cell::sync::OnceCell;
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)]
use trust_dns_resolver::config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts};
use trust_dns_resolver::TokioAsyncResolver;
type BoxError = Box<dyn std::error::Error + Send + Sync>;