Skip to content

Commit

Permalink
[meta] fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshowers committed Nov 30, 2024
1 parent 665f3f5 commit 2754d80
Show file tree
Hide file tree
Showing 31 changed files with 69 additions and 72 deletions.
4 changes: 2 additions & 2 deletions cargo-guppy/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<'a> Deref for Package<'a> {
}
}

impl<'a> Serialize for Package<'a> {
impl Serialize for Package<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -143,7 +143,7 @@ pub struct Diff<'a> {
added: Vec<(Package<'a>, Option<Vec<Package<'a>>>)>,
}

impl<'a> ::std::fmt::Display for Diff<'a> {
impl ::std::fmt::Display for Diff<'_> {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fn write_dups(
f: &mut ::std::fmt::Formatter<'_>,
Expand Down
2 changes: 1 addition & 1 deletion cargo-guppy/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ struct ManifestEdit<'g> {
edit_path: Utf8PathBuf,
}

impl<'g> fmt::Display for ManifestEdit<'g> {
impl fmt::Display for ManifestEdit<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/src/dep_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a> DirectionDesc<'a> {
}
}

impl<'a> From<DependencyDirection> for DirectionDesc<'a> {
impl From<DependencyDirection> for DirectionDesc<'_> {
fn from(direction: DependencyDirection) -> Self {
Self::new(direction)
}
Expand Down
2 changes: 1 addition & 1 deletion guppy-summaries/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub(crate) fn changed_sort_key<'a>(
(status.tag(), status.latest_status(), summary_id)
}

impl<'a> Serialize for PackageDiff<'a> {
impl Serialize for PackageDiff<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down
4 changes: 2 additions & 2 deletions guppy-summaries/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'a, 'b> SummaryReport<'a, 'b> {
}
}

impl<'a, 'b> fmt::Display for SummaryReport<'a, 'b> {
impl fmt::Display for SummaryReport<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if !self.diff.target_packages.is_unchanged() {
writeln!(
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<'x> PackageReport<'x> {
}
}

impl<'x> fmt::Display for PackageReport<'x> {
impl fmt::Display for PackageReport<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for (summary_id, status) in self.sorted {
write!(
Expand Down
10 changes: 5 additions & 5 deletions guppy/src/graph/build_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub(super) trait BuildTargetKey {
fn key(&self) -> BuildTargetId;
}

impl<'g> BuildTargetKey for BuildTargetId<'g> {
impl BuildTargetKey for BuildTargetId<'_> {
fn key(&self) -> BuildTargetId {
*self
}
Expand All @@ -253,23 +253,23 @@ impl<'g> Borrow<dyn BuildTargetKey + 'g> for OwnedBuildTargetId {
}
}

impl<'g> PartialEq for (dyn BuildTargetKey + 'g) {
impl PartialEq for (dyn BuildTargetKey + '_) {
fn eq(&self, other: &Self) -> bool {
self.key() == other.key()
}
}

impl<'g> Eq for (dyn BuildTargetKey + 'g) {}
impl Eq for (dyn BuildTargetKey + '_) {}

// For Borrow to be upheld, PartialOrd and Ord should be consistent. This is checked by the proptest
// below.
impl<'g> PartialOrd for (dyn BuildTargetKey + 'g) {
impl PartialOrd for (dyn BuildTargetKey + '_) {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl<'g> Ord for (dyn BuildTargetKey + 'g) {
impl Ord for (dyn BuildTargetKey + '_) {
fn cmp(&self, other: &Self) -> Ordering {
self.key().cmp(&other.key())
}
Expand Down
2 changes: 1 addition & 1 deletion guppy/src/graph/cargo/cargo_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'a> CargoOptions<'a> {
}
}

impl<'a> Default for CargoOptions<'a> {
impl Default for CargoOptions<'_> {
fn default() -> Self {
Self::new()
}
Expand Down
1 change: 0 additions & 1 deletion guppy/src/graph/cycles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ use crate::{
/// [serde_github]: https://github.com/serde-rs/serde
/// [serde_toml]: https://github.com/serde-rs/serde/blob/072145e0e913df7686f001dbf29e43a0ff7afac4/serde/Cargo.toml#L17-L18
/// [serde_derive_toml]: https://github.com/serde-rs/serde/blob/072145e0e913df7686f001dbf29e43a0ff7afac4/serde_derive/Cargo.toml#L29-L30
pub struct Cycles<'g> {
package_graph: &'g PackageGraph,
sccs: &'g Sccs<PackageIx>,
Expand Down
8 changes: 4 additions & 4 deletions guppy/src/graph/feature/feature_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<'g> FeatureList<'g> {
}
}

impl<'g> fmt::Debug for FeatureList<'g> {
impl fmt::Debug for FeatureList<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FeatureList")
.field("package", self.package.id())
Expand Down Expand Up @@ -182,7 +182,7 @@ impl<'g, 'a> Iter<'g, 'a> {
}
}

impl<'g, 'a> Iterator for Iter<'g, 'a> {
impl<'g> Iterator for Iter<'g, '_> {
type Item = FeatureId<'g>;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -198,7 +198,7 @@ impl<'g, 'a> Iterator for Iter<'g, 'a> {
#[derive(Clone, Copy)]
pub struct DisplayFeatures<'g, 'a>(&'a [FeatureLabel<'g>]);

impl<'g, 'a> fmt::Display for DisplayFeatures<'g, 'a> {
impl fmt::Display for DisplayFeatures<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let len = self.0.len();
for (idx, label) in self.0.iter().enumerate() {
Expand All @@ -211,7 +211,7 @@ impl<'g, 'a> fmt::Display for DisplayFeatures<'g, 'a> {
}
}

impl<'g, 'a> fmt::Debug for DisplayFeatures<'g, 'a> {
impl fmt::Debug for DisplayFeatures<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Use the Display impl as the debug one because it's easier to read.
write!(f, "{}", self)
Expand Down
7 changes: 3 additions & 4 deletions guppy/src/graph/feature/graph_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ impl<'g> From<(&'g PackageId, FeatureLabel<'g>)> for FeatureId<'g> {
/// "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)/dep:bar"
/// );
/// ```
impl<'g> fmt::Display for FeatureId<'g> {
impl fmt::Display for FeatureId<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}/{}", self.package_id, self.label)
}
Expand All @@ -552,7 +552,7 @@ pub enum FeatureLabel<'g> {
OptionalDependency(&'g str),
}

impl<'g> FeatureLabel<'g> {
impl FeatureLabel<'_> {
/// Returns the kind of feature this is.
///
/// The kind of a feature is simply the enum variant without any associated data.
Expand Down Expand Up @@ -581,8 +581,7 @@ impl<'g> FeatureLabel<'g> {
/// assert_eq!(format!("{}", FeatureLabel::Named("foo")), "foo");
/// assert_eq!(format!("{}", FeatureLabel::OptionalDependency("bar")), "dep:bar");
/// ```
impl<'g> fmt::Display for FeatureLabel<'g> {
impl fmt::Display for FeatureLabel<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Base => write!(f, "[base]"),
Expand Down
12 changes: 6 additions & 6 deletions guppy/src/graph/feature/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait FeatureFilter<'g> {
fn accept(&mut self, graph: &FeatureGraph<'g>, feature_id: FeatureId<'g>) -> bool;
}

impl<'g, 'a, T> FeatureFilter<'g> for &'a mut T
impl<'g, T> FeatureFilter<'g> for &mut T
where
T: FeatureFilter<'g>,
{
Expand All @@ -46,13 +46,13 @@ where
}
}

impl<'g, 'a> FeatureFilter<'g> for Box<dyn FeatureFilter<'g> + 'a> {
impl<'g> FeatureFilter<'g> for Box<dyn FeatureFilter<'g> + '_> {
fn accept(&mut self, graph: &FeatureGraph<'g>, feature_id: FeatureId<'g>) -> bool {
(**self).accept(graph, feature_id)
}
}

impl<'g, 'a> FeatureFilter<'g> for &'a mut dyn FeatureFilter<'g> {
impl<'g> FeatureFilter<'g> for &mut dyn FeatureFilter<'g> {
fn accept(&mut self, graph: &FeatureGraph<'g>, feature_id: FeatureId<'g>) -> bool {
(**self).accept(graph, feature_id)
}
Expand Down Expand Up @@ -348,7 +348,7 @@ pub trait FeatureResolver<'g> {
fn accept(&mut self, query: &FeatureQuery<'g>, link: ConditionalLink<'g>) -> bool;
}

impl<'g, 'a, T> FeatureResolver<'g> for &'a mut T
impl<'g, T> FeatureResolver<'g> for &mut T
where
T: FeatureResolver<'g>,
{
Expand All @@ -357,13 +357,13 @@ where
}
}

impl<'g, 'a> FeatureResolver<'g> for Box<dyn FeatureResolver<'g> + 'a> {
impl<'g> FeatureResolver<'g> for Box<dyn FeatureResolver<'g> + '_> {
fn accept(&mut self, query: &FeatureQuery<'g>, link: ConditionalLink<'g>) -> bool {
(**self).accept(query, link)
}
}

impl<'g, 'a> FeatureResolver<'g> for &'a mut dyn FeatureResolver<'g> {
impl<'g> FeatureResolver<'g> for &mut dyn FeatureResolver<'g> {
fn accept(&mut self, query: &FeatureQuery<'g>, link: ConditionalLink<'g>) -> bool {
(**self).accept(query, link)
}
Expand Down
6 changes: 3 additions & 3 deletions guppy/src/graph/feature/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct FeatureSet<'g> {
core: ResolveCore<FeatureGraphSpec>,
}

impl<'g> fmt::Debug for FeatureSet<'g> {
impl fmt::Debug for FeatureSet<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_set()
.entries(self.packages_with_features(DependencyDirection::Forward))
Expand Down Expand Up @@ -605,11 +605,11 @@ impl<'g> FeatureSet<'g> {
}
}

impl<'g> PartialEq for FeatureSet<'g> {
impl PartialEq for FeatureSet<'_> {
fn eq(&self, other: &Self) -> bool {
::std::ptr::eq(self.graph.package_graph, other.graph.package_graph)
&& self.core == other.core
}
}

impl<'g> Eq for FeatureSet<'g> {}
impl Eq for FeatureSet<'_> {}
2 changes: 1 addition & 1 deletion guppy/src/graph/feature/weak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub(super) enum SingleBufferState<'g> {
Accepted,
}

impl<'g> Default for SingleBufferState<'g> {
impl Default for SingleBufferState<'_> {
fn default() -> Self {
Self::Buffered(SingleBufferVec::new())
}
Expand Down
10 changes: 5 additions & 5 deletions guppy/src/graph/graph_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ pub struct PackageMetadata<'g> {
inner: &'g PackageMetadataImpl,
}

impl<'g> fmt::Debug for PackageMetadata<'g> {
impl fmt::Debug for PackageMetadata<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("PackageMetadata")
.field("package_id", &self.id().repr())
Expand Down Expand Up @@ -1168,15 +1168,15 @@ pub(crate) enum FeatureIndexInPackage {
}

/// `PackageMetadata`'s `PartialEq` implementation uses pointer equality for the `PackageGraph`.
impl<'g> PartialEq for PackageMetadata<'g> {
impl PartialEq for PackageMetadata<'_> {
fn eq(&self, other: &Self) -> bool {
// Checking for the same package ix is enough as each package is guaranteed to be a 1:1 map
// with ixs.
std::ptr::eq(self.graph, other.graph) && self.package_ix() == other.package_ix()
}
}

impl<'g> Eq for PackageMetadata<'g> {}
impl Eq for PackageMetadata<'_> {}

#[derive(Clone, Debug)]
pub(crate) struct PackageMetadataImpl {
Expand Down Expand Up @@ -1326,7 +1326,7 @@ impl<'g> PackageSource<'g> {
}
}

impl<'g> fmt::Display for PackageSource<'g> {
impl fmt::Display for PackageSource<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
PackageSource::Workspace(path) => write!(f, "{}", path),
Expand Down Expand Up @@ -1551,7 +1551,7 @@ impl<'g> ExternalSource<'g> {
/// "git+https://github.com/rust-lang/cargo.git?branch=main#0227f048fcb7c798026ede6cc20c92befc84c3a4",
/// );
/// ```
impl<'g> fmt::Display for ExternalSource<'g> {
impl fmt::Display for ExternalSource<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ExternalSource::Registry(url) => write!(f, "{}{}", Self::REGISTRY_PLUS, url),
Expand Down
10 changes: 5 additions & 5 deletions guppy/src/graph/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,13 @@ impl<'g> PackageSet<'g> {
}
}

impl<'g> PartialEq for PackageSet<'g> {
impl PartialEq for PackageSet<'_> {
fn eq(&self, other: &Self) -> bool {
::std::ptr::eq(self.graph.0, other.graph.0) && self.core == other.core
}
}

impl<'g> Eq for PackageSet<'g> {}
impl Eq for PackageSet<'_> {}

/// Represents whether a particular link within a package graph should be followed during a
/// resolve operation.
Expand All @@ -561,7 +561,7 @@ pub trait PackageResolver<'g> {
fn accept(&mut self, query: &PackageQuery<'g>, link: PackageLink<'g>) -> bool;
}

impl<'g, 'a, T> PackageResolver<'g> for &'a mut T
impl<'g, T> PackageResolver<'g> for &mut T
where
T: PackageResolver<'g>,
{
Expand All @@ -570,13 +570,13 @@ where
}
}

impl<'g, 'a> PackageResolver<'g> for Box<dyn PackageResolver<'g> + 'a> {
impl<'g> PackageResolver<'g> for Box<dyn PackageResolver<'g> + '_> {
fn accept(&mut self, query: &PackageQuery<'g>, link: PackageLink<'g>) -> bool {
(**self).accept(query, link)
}
}

impl<'g, 'a> PackageResolver<'g> for &'a mut dyn PackageResolver<'g> {
impl<'g> PackageResolver<'g> for &mut dyn PackageResolver<'g> {
fn accept(&mut self, query: &PackageQuery<'g>, link: PackageLink<'g>) -> bool {
(**self).accept(query, link)
}
Expand Down
6 changes: 3 additions & 3 deletions guppy/src/graph/resolve_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub(super) struct Topo<'g, G: GraphSpec> {
remaining: usize,
}

impl<'g, G: GraphSpec> Iterator for Topo<'g, G> {
impl<G: GraphSpec> Iterator for Topo<'_, G> {
type Item = NodeIndex<G::Ix>;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -290,7 +290,7 @@ impl<'g, G: GraphSpec> Iterator for Topo<'g, G> {
}
}

impl<'g, G: GraphSpec> ExactSizeIterator for Topo<'g, G> {
impl<G: GraphSpec> ExactSizeIterator for Topo<'_, G> {
fn len(&self) -> usize {
self.remaining
}
Expand All @@ -306,7 +306,7 @@ pub(super) struct Links<'g, G: GraphSpec> {
direction: DependencyDirection,
}

impl<'g, G: GraphSpec> Iterator for Links<'g, G> {
impl<G: GraphSpec> Iterator for Links<'_, G> {
#[allow(clippy::type_complexity)]
type Item = (NodeIndex<G::Ix>, NodeIndex<G::Ix>, EdgeIndex<G::Ix>);

Expand Down
Loading

0 comments on commit 2754d80

Please sign in to comment.