Make the use of Self consistent. (#15074)

## Summary

Make the use of `Self` consistent. Mostly done by running `cargo clippy
--fix -- -A clippy::all -W clippy::use_self`.

## Test Plan

<!-- How was it tested? -->
No need.
This commit is contained in:
adamnemecek 2025-08-05 12:17:12 -07:00 committed by GitHub
parent 57f900ad0d
commit 3f83390e34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
121 changed files with 1305 additions and 1376 deletions

View file

@ -1051,7 +1051,7 @@ pub struct ManagedClient<'a> {
impl<'a> ManagedClient<'a> {
/// Create a new `ManagedClient` using the given client and concurrency limit.
fn new(client: &'a RegistryClient, concurrency: usize) -> ManagedClient<'a> {
fn new(client: &'a RegistryClient, concurrency: usize) -> Self {
ManagedClient {
unmanaged: client,
control: Semaphore::new(concurrency),
@ -1176,7 +1176,7 @@ impl LocalArchivePointer {
/// Read an [`LocalArchivePointer`] from the cache.
pub fn read_from(path: impl AsRef<Path>) -> Result<Option<Self>, Error> {
match fs_err::read(path) {
Ok(cached) => Ok(Some(rmp_serde::from_slice::<LocalArchivePointer>(&cached)?)),
Ok(cached) => Ok(Some(rmp_serde::from_slice::<Self>(&cached)?)),
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(None),
Err(err) => Err(Error::CacheRead(err)),
}

View file

@ -55,8 +55,8 @@ impl Hashed for LocalWheel {
/// Convert a [`LocalWheel`] into a [`CachedDist`].
impl From<LocalWheel> for CachedDist {
fn from(wheel: LocalWheel) -> CachedDist {
CachedDist::from_remote(
fn from(wheel: LocalWheel) -> Self {
Self::from_remote(
wheel.dist,
wheel.filename,
wheel.hashes,

View file

@ -189,7 +189,7 @@ impl Error {
distribution: String,
expected: &[HashDigest],
actual: &[HashDigest],
) -> Error {
) -> Self {
match (expected.is_empty(), actual.is_empty()) {
(true, true) => Self::MissingHashes { distribution },
(true, false) => {

View file

@ -149,7 +149,7 @@ impl LoweredRequirement {
let mut remaining = total.negate();
remaining.and(requirement.marker);
LoweredRequirement(Requirement {
Self(Requirement {
marker: remaining,
..Requirement::from(requirement.clone())
})
@ -389,7 +389,7 @@ impl LoweredRequirement {
let mut remaining = total.negate();
remaining.and(requirement.marker);
LoweredRequirement(Requirement {
Self(Requirement {
marker: remaining,
..Requirement::from(requirement.clone())
})
@ -565,10 +565,10 @@ pub enum SourceKind {
impl std::fmt::Display for SourceKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SourceKind::Path => write!(f, "path"),
SourceKind::Url => write!(f, "URL"),
SourceKind::Git => write!(f, "Git"),
SourceKind::Registry => write!(f, "registry"),
Self::Path => write!(f, "path"),
Self::Url => write!(f, "URL"),
Self::Git => write!(f, "Git"),
Self::Registry => write!(f, "registry"),
}
}
}

View file

@ -2889,9 +2889,7 @@ impl LocalRevisionPointer {
/// Read an [`LocalRevisionPointer`] from the cache.
pub(crate) fn read_from(path: impl AsRef<Path>) -> Result<Option<Self>, Error> {
match fs_err::read(path) {
Ok(cached) => Ok(Some(rmp_serde::from_slice::<LocalRevisionPointer>(
&cached,
)?)),
Ok(cached) => Ok(Some(rmp_serde::from_slice::<Self>(&cached)?)),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None),
Err(err) => Err(Error::CacheRead(err)),
}