Fix some nightly lints (#15028)

Apply fixes for some `cargo check` and `cargo clippy` lints that are on
in nightly Rust.

The following command now passes, the blanket allows had to many
false-positives:

```
cargo +nightly clippy -- -A clippy::doc_markdown -A mismatched_lifetime_syntaxes -A clippy::explicit_deref_methods
```

`cargo +nightly check -- -A mismatched_lifetime_syntaxes` now passes
without warnings.
This commit is contained in:
konsti 2025-08-02 20:59:23 +02:00 committed by GitHub
parent 025d209735
commit 368b7b1e12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 43 additions and 51 deletions

View file

@ -140,12 +140,10 @@ impl FromStr for LanguageTag {
Ok(Self::None) Ok(Self::None)
} else if let Some(py) = s.strip_prefix("py") { } else if let Some(py) = s.strip_prefix("py") {
match py.len() { match py.len() {
0 => { 0 => Err(ParseLanguageTagError::MissingMajorVersion {
return Err(ParseLanguageTagError::MissingMajorVersion {
implementation: "Python", implementation: "Python",
tag: s.to_string(), tag: s.to_string(),
}); }),
}
1 => { 1 => {
// Ex) `py3` // Ex) `py3`
let major = py let major = py

View file

@ -1606,7 +1606,7 @@ impl PylockTomlArchive {
} }
} }
} else { } else {
return Err(PylockTomlErrorKind::ArchiveMissingPathUrl(name.clone())); Err(PylockTomlErrorKind::ArchiveMissingPathUrl(name.clone()))
} }
} }
@ -1631,7 +1631,7 @@ impl PylockTomlArchive {
let ext = DistExtension::from_path(filename)?; let ext = DistExtension::from_path(filename)?;
Ok(matches!(ext, DistExtension::Wheel)) Ok(matches!(ext, DistExtension::Wheel))
} else { } else {
return Err(PylockTomlErrorKind::ArchiveMissingPathUrl(name.clone())); Err(PylockTomlErrorKind::ArchiveMissingPathUrl(name.clone()))
} }
} }
} }

View file

@ -1,6 +1,5 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::{BTreeMap, BTreeSet, VecDeque}; use std::collections::{BTreeMap, BTreeSet, VecDeque};
use std::convert::Infallible;
use std::error::Error; use std::error::Error;
use std::fmt::{Debug, Display, Formatter}; use std::fmt::{Debug, Display, Formatter};
use std::io; use std::io;
@ -3907,7 +3906,7 @@ struct SourceDistMetadata {
/// future, so this should be treated as only a hint to where to look /// future, so this should be treated as only a hint to where to look
/// and/or recording where the source dist file originally came from. /// and/or recording where the source dist file originally came from.
#[derive(Clone, Debug, serde::Deserialize, PartialEq, Eq)] #[derive(Clone, Debug, serde::Deserialize, PartialEq, Eq)]
#[serde(try_from = "SourceDistWire")] #[serde(from = "SourceDistWire")]
enum SourceDist { enum SourceDist {
Url { Url {
url: UrlString, url: UrlString,
@ -4206,17 +4205,15 @@ impl SourceDist {
} }
} }
impl TryFrom<SourceDistWire> for SourceDist { impl From<SourceDistWire> for SourceDist {
type Error = Infallible; fn from(wire: SourceDistWire) -> SourceDist {
fn try_from(wire: SourceDistWire) -> Result<SourceDist, Infallible> {
match wire { match wire {
SourceDistWire::Url { url, metadata } => Ok(SourceDist::Url { url, metadata }), SourceDistWire::Url { url, metadata } => SourceDist::Url { url, metadata },
SourceDistWire::Path { path, metadata } => Ok(SourceDist::Path { SourceDistWire::Path { path, metadata } => SourceDist::Path {
path: path.into(), path: path.into(),
metadata, metadata,
}), },
SourceDistWire::Metadata { metadata } => Ok(SourceDist::Metadata { metadata }), SourceDistWire::Metadata { metadata } => SourceDist::Metadata { metadata },
} }
} }
} }

View file

@ -523,8 +523,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
)?; )?;
// Pick the next compatible version. // Pick the next compatible version.
let version = match decision { let Some(version) = decision else {
None => {
debug!("No compatible version found for: {next_package}"); debug!("No compatible version found for: {next_package}");
let term_intersection = state let term_intersection = state
@ -536,13 +535,13 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
if let PubGrubPackageInner::Package { name, .. } = &**next_package { if let PubGrubPackageInner::Package { name, .. } = &**next_package {
// Check if the decision was due to the package being unavailable // Check if the decision was due to the package being unavailable
if let Some(entry) = self.unavailable_packages.get(name) { if let Some(entry) = self.unavailable_packages.get(name) {
state.pubgrub.add_incompatibility( state
Incompatibility::custom_term( .pubgrub
.add_incompatibility(Incompatibility::custom_term(
next_id, next_id,
term_intersection.clone(), term_intersection.clone(),
UnavailableReason::Package(entry.clone()), UnavailableReason::Package(entry.clone()),
), ));
);
continue; continue;
} }
} }
@ -554,8 +553,6 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
term_intersection.clone(), term_intersection.clone(),
)); ));
continue; continue;
}
Some(version) => version,
}; };
let version = match version { let version = match version {

View file

@ -248,7 +248,7 @@ pub(crate) async fn sync(
}); });
match update_environment( match update_environment(
Deref::deref(&environment).clone(), environment.clone(),
spec, spec,
modifications, modifications,
build_constraints.unwrap_or_default(), build_constraints.unwrap_or_default(),

View file

@ -1437,9 +1437,9 @@ impl AddSettings {
// Warn user if an ambiguous relative path was passed as a value for // Warn user if an ambiguous relative path was passed as a value for
// `--index` or `--default-index`. // `--index` or `--default-index`.
indexes for index in &indexes {
.iter() index.url().warn_on_disambiguated_relative_path();
.for_each(|index| index.url().warn_on_disambiguated_relative_path()); }
// If the user passed an `--index-url` or `--extra-index-url`, warn. // If the user passed an `--index-url` or `--extra-index-url`, warn.
if installer if installer