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)
} else if let Some(py) = s.strip_prefix("py") {
match py.len() {
0 => {
return Err(ParseLanguageTagError::MissingMajorVersion {
0 => Err(ParseLanguageTagError::MissingMajorVersion {
implementation: "Python",
tag: s.to_string(),
});
}
}),
1 => {
// Ex) `py3`
let major = py

View file

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

View file

@ -1,6 +1,5 @@
use std::borrow::Cow;
use std::collections::{BTreeMap, BTreeSet, VecDeque};
use std::convert::Infallible;
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::io;
@ -3907,7 +3906,7 @@ struct SourceDistMetadata {
/// 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.
#[derive(Clone, Debug, serde::Deserialize, PartialEq, Eq)]
#[serde(try_from = "SourceDistWire")]
#[serde(from = "SourceDistWire")]
enum SourceDist {
Url {
url: UrlString,
@ -4206,17 +4205,15 @@ impl SourceDist {
}
}
impl TryFrom<SourceDistWire> for SourceDist {
type Error = Infallible;
fn try_from(wire: SourceDistWire) -> Result<SourceDist, Infallible> {
impl From<SourceDistWire> for SourceDist {
fn from(wire: SourceDistWire) -> SourceDist {
match wire {
SourceDistWire::Url { url, metadata } => Ok(SourceDist::Url { url, metadata }),
SourceDistWire::Path { path, metadata } => Ok(SourceDist::Path {
SourceDistWire::Url { url, metadata } => SourceDist::Url { url, metadata },
SourceDistWire::Path { path, metadata } => SourceDist::Path {
path: path.into(),
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.
let version = match decision {
None => {
let Some(version) = decision else {
debug!("No compatible version found for: {next_package}");
let term_intersection = state
@ -536,13 +535,13 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
if let PubGrubPackageInner::Package { name, .. } = &**next_package {
// Check if the decision was due to the package being unavailable
if let Some(entry) = self.unavailable_packages.get(name) {
state.pubgrub.add_incompatibility(
Incompatibility::custom_term(
state
.pubgrub
.add_incompatibility(Incompatibility::custom_term(
next_id,
term_intersection.clone(),
UnavailableReason::Package(entry.clone()),
),
);
));
continue;
}
}
@ -554,8 +553,6 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
term_intersection.clone(),
));
continue;
}
Some(version) => version,
};
let version = match version {

View file

@ -248,7 +248,7 @@ pub(crate) async fn sync(
});
match update_environment(
Deref::deref(&environment).clone(),
environment.clone(),
spec,
modifications,
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
// `--index` or `--default-index`.
indexes
.iter()
.for_each(|index| index.url().warn_on_disambiguated_relative_path());
for index in &indexes {
index.url().warn_on_disambiguated_relative_path();
}
// If the user passed an `--index-url` or `--extra-index-url`, warn.
if installer