Skip to content

Commit

Permalink
[meta] update style_version to 2024 (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshowers authored Feb 22, 2025
1 parent a0ad2c4 commit 4722ab3
Show file tree
Hide file tree
Showing 81 changed files with 202 additions and 214 deletions.
4 changes: 2 additions & 2 deletions cargo-guppy/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//! Implementations for options shared by commands.
use clap::{ArgEnum, Parser};
use color_eyre::eyre::{ensure, eyre, Result, WrapErr};
use color_eyre::eyre::{Result, WrapErr, ensure, eyre};
use guppy::{
PackageId,
graph::{DependencyDirection, DependencyReq, PackageGraph, PackageLink, PackageQuery},
platform::EnabledTernary,
PackageId,
};
use guppy_cmdlib::string_to_platform_spec;
use std::collections::HashSet;
Expand Down
4 changes: 2 additions & 2 deletions cargo-guppy/src/diff.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) The cargo-guppy Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

use guppy::{graph::PackageMetadata, PackageId};
use serde::{ser::SerializeStruct, Serialize, Serializer};
use guppy::{PackageId, graph::PackageMetadata};
use serde::{Serialize, Serializer, ser::SerializeStruct};
use std::{collections::HashMap, ops::Deref};

#[derive(Debug, Default)]
Expand Down
10 changes: 5 additions & 5 deletions cargo-guppy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ pub use crate::{core::*, mv::*};
use ahash::AHashMap;
use camino::Utf8PathBuf;
use clap::{ArgEnum, Parser};
use color_eyre::eyre::{bail, Result, WrapErr};
use color_eyre::eyre::{Result, WrapErr, bail};
use guppy::{
PackageId,
graph::{
DependencyDirection, DotWrite, PackageDotVisitor, PackageGraph, PackageLink,
PackageMetadata,
cargo::{CargoOptions, CargoSet},
feature::{FeatureSet, StandardFeatures},
summaries::Summary,
DependencyDirection, DotWrite, PackageDotVisitor, PackageGraph, PackageLink,
PackageMetadata,
},
PackageId,
};
use guppy_cmdlib::{
string_to_platform_spec, CargoMetadataOptions, CargoResolverOpts, PackagesAndFeatures,
CargoMetadataOptions, CargoResolverOpts, PackagesAndFeatures, string_to_platform_spec,
};
use std::{borrow::Cow, cmp, collections::HashSet, fmt, fs, io::Write, iter, path::PathBuf};

Expand Down
6 changes: 3 additions & 3 deletions cargo-guppy/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

use camino::{Utf8Path, Utf8PathBuf};
use clap::Parser;
use color_eyre::eyre::{bail, eyre, Result, WrapErr};
use color_eyre::eyre::{Result, WrapErr, bail, eyre};
use dialoguer::Confirm;
use guppy::graph::{PackageGraph, PackageLink, PackageMetadata};
use guppy_cmdlib::CargoMetadataOptions;
use pathdiff::diff_utf8_paths;
use std::{
collections::{btree_map::Entry, BTreeMap, HashSet},
collections::{BTreeMap, HashSet, btree_map::Entry},
fmt, fs,
io::{self, Write},
mem,
path::{Path, MAIN_SEPARATOR},
path::{MAIN_SEPARATOR, Path},
};
use toml_edit::{DocumentMut, Item, Table, Value};

Expand Down
4 changes: 2 additions & 2 deletions fixtures/src/dep_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

use crate::details::PackageDetails;
use guppy::{
DependencyKind, Error, PackageId,
graph::{
feature::{FeatureGraph, FeatureId, FeatureMetadata, FeatureQuery, FeatureSet},
DependencyDirection, DependencyReq, PackageGraph, PackageLink, PackageLinkPtrs,
PackageMetadata, PackageQuery, PackageSet,
feature::{FeatureGraph, FeatureId, FeatureMetadata, FeatureQuery, FeatureSet},
},
platform::PlatformSpec,
DependencyKind, Error, PackageId,
};
use pretty_assertions::assert_eq;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion fixtures/src/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use crate::{
use ahash::AHashMap;
use camino::Utf8PathBuf;
use guppy::{
DependencyKind, PackageId, Version,
errors::FeatureGraphWarning,
graph::{
BuildTargetId, BuildTargetKind, DependencyDirection, EnabledStatus, PackageGraph,
PackageLink, PackageMetadata, PackageSource, Workspace,
},
platform::{EnabledTernary, Platform, PlatformSpec},
DependencyKind, PackageId, Version,
};
use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
Expand Down
20 changes: 7 additions & 13 deletions fixtures/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use crate::{
use ahash::AHashMap;
use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
use guppy::{
CargoMetadata, DependencyKind,
errors::{FeatureBuildStage, FeatureGraphWarning},
graph::{BuildTargetId, BuildTargetKind, PackageGraph},
platform::{EnabledTernary, Platform, TargetFeatures},
CargoMetadata, DependencyKind,
};
use once_cell::sync::{Lazy, OnceCell};
use std::{collections::BTreeMap, fs};
Expand Down Expand Up @@ -48,10 +48,8 @@ pub static METADATA_DUPS_BYTES_05: &str =
"bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)";

pub static METADATA_CYCLE1_PATH: &str = "../small/metadata_cycle1.json";
pub static METADATA_CYCLE1_BASE: &str =
"testcycles-base 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcycles/testcycles-base)";
pub static METADATA_CYCLE1_HELPER: &str =
"testcycles-helper 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcycles/testcycles-helper)";
pub static METADATA_CYCLE1_BASE: &str = "testcycles-base 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcycles/testcycles-base)";
pub static METADATA_CYCLE1_HELPER: &str = "testcycles-helper 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcycles/testcycles-helper)";

pub static METADATA_CYCLE2_PATH: &str = "../small/metadata_cycle2.json";
pub static METADATA_CYCLE2_UPPER_A: &str =
Expand Down Expand Up @@ -111,8 +109,7 @@ pub static METADATA_WEAK_NAMESPACED_TINYVEC: &str =
"tinyvec 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)";

pub static METADATA_LIBRA_PATH: &str = "../large/metadata_libra.json";
pub static METADATA_LIBRA_ADMISSION_CONTROL_SERVICE: &str =
"admission-control-service 0.1.0 (path+file:///Users/fakeuser/local/libra/admission_control/admission-control-service)";
pub static METADATA_LIBRA_ADMISSION_CONTROL_SERVICE: &str = "admission-control-service 0.1.0 (path+file:///Users/fakeuser/local/libra/admission_control/admission-control-service)";
pub static METADATA_LIBRA_COMPILER: &str =
"compiler 0.1.0 (path+file:///Users/fakeuser/local/libra/language/compiler)";
pub static METADATA_LIBRA_E2E_TESTS: &str =
Expand All @@ -137,16 +134,13 @@ pub static METADATA_LIBRA_MOVE_VM_RUNTIME: &str =
"move-vm-runtime 0.1.0 (path+file:///Users/fakeuser/local/libra/language/move-vm/runtime)";
pub static METADATA_LIBRA_STDLIB: &str =
"stdlib 0.1.0 (path+file:///Users/fakeuser/local/libra/language/stdlib)";
pub static METADATA_LIBRA_TEST_GENERATION: &str =
"test-generation 0.1.0 (path+file:///Users/fakeuser/local/libra/language/tools/test-generation)";
pub static METADATA_LIBRA_TRANSACTION_BUILDER: &str =
"transaction-builder 0.1.0 (path+file:///Users/fakeuser/local/libra/language/transaction-builder)";
pub static METADATA_LIBRA_TEST_GENERATION: &str = "test-generation 0.1.0 (path+file:///Users/fakeuser/local/libra/language/tools/test-generation)";
pub static METADATA_LIBRA_TRANSACTION_BUILDER: &str = "transaction-builder 0.1.0 (path+file:///Users/fakeuser/local/libra/language/transaction-builder)";
pub static METADATA_LIBRA_VM_GENESIS: &str =
"vm-genesis 0.1.0 (path+file:///Users/fakeuser/local/libra/language/tools/vm-genesis)";
pub static METADATA_LIBRA_LANGUAGE_BENCHMARKS: &str =
"language_benchmarks 0.1.0 (path+file:///Users/fakeuser/local/libra/language/benchmarks)";
pub static METADATA_LIBRA_TREE_HEAP: &str =
"tree_heap 0.1.0 (path+file:///Users/fakeuser/local/libra/language/stackless-bytecode/tree_heap)";
pub static METADATA_LIBRA_TREE_HEAP: &str = "tree_heap 0.1.0 (path+file:///Users/fakeuser/local/libra/language/stackless-bytecode/tree_heap)";
pub static METADATA_LIBRA_LAZY_STATIC: &str =
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)";
pub static METADATA_LIBRA_BACKTRACE: &str =
Expand Down
6 changes: 3 additions & 3 deletions guppy-cmdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ pub mod proptest;
use clap::{ArgEnum, Parser};
use color_eyre::eyre::Result;
use guppy::{
MetadataCommand,
graph::{
cargo::{CargoResolverVersion, InitialsPlatform},
feature::{named_feature_filter, FeatureSet, StandardFeatures},
PackageGraph,
cargo::{CargoResolverVersion, InitialsPlatform},
feature::{FeatureSet, StandardFeatures, named_feature_filter},
},
platform::{Platform, PlatformSpec, TargetFeatures},
MetadataCommand,
};
use std::{env, path::PathBuf};

Expand Down
11 changes: 7 additions & 4 deletions guppy-summaries/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
pub use crate::report::SummaryReport;
use crate::{PackageInfo, PackageMap, PackageStatus, Summary, SummaryId, SummarySource};
use ahash::AHashMap;
use diffus::{edit, Diffable};
use diffus::{Diffable, edit};
use semver::Version;
use serde::{ser::SerializeStruct, Serialize};
use serde::{Serialize, ser::SerializeStruct};
use std::{
collections::{BTreeMap, BTreeSet},
fmt, mem,
Expand Down Expand Up @@ -384,8 +384,11 @@ impl<'a> SummaryDiffStatus<'a> {
let [added_features, removed_features, unchanged_features] =
Self::make_changed_diff(&old_info.features, &new_info.features);

let [added_optional_deps, removed_optional_deps, unchanged_optional_deps] =
Self::make_changed_diff(&old_info.optional_deps, &new_info.optional_deps);
let [
added_optional_deps,
removed_optional_deps,
unchanged_optional_deps,
] = Self::make_changed_diff(&old_info.optional_deps, &new_info.optional_deps);

SummaryDiffStatus::Modified {
old_version,
Expand Down
2 changes: 1 addition & 1 deletion guppy-summaries/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::{
diff::{changed_sort_key, PackageDiff, SummaryDiff, SummaryDiffStatus},
SummaryId,
diff::{PackageDiff, SummaryDiff, SummaryDiffStatus, changed_sort_key},
};
use std::fmt;

Expand Down
4 changes: 2 additions & 2 deletions guppy-summaries/src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
collections::{BTreeMap, BTreeSet},
fmt,
};
use toml::{value::Table, Serializer};
use toml::{Serializer, value::Table};

/// A type representing a package map as used in `Summary` instances.
pub type PackageMap = BTreeMap<SummaryId, PackageInfo>;
Expand Down Expand Up @@ -332,7 +332,7 @@ fn path_replace_slashes(path: &Utf8Path) -> impl fmt::Display + Serialize + '_ {
/// Serialization and deserialization for the `CratesIo` variant.
mod crates_io_impl {
use super::*;
use serde::{de::Error, ser::SerializeMap, Deserializer, Serializer};
use serde::{Deserializer, Serializer, de::Error, ser::SerializeMap};

pub fn serialize<S>(serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
4 changes: 2 additions & 2 deletions guppy-summaries/src/unit_tests/basic_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::{
diff::SummaryDiffStatus, PackageInfo, PackageMap, PackageStatus, Summary, SummaryId,
SummarySource,
PackageInfo, PackageMap, PackageStatus, Summary, SummaryId, SummarySource,
diff::SummaryDiffStatus,
};
use pretty_assertions::assert_eq;
use semver::Version;
Expand Down
2 changes: 1 addition & 1 deletion guppy/examples/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//! Print out direct and transitive dependencies of a package.
use guppy::{graph::DependencyDirection, CargoMetadata, Error, PackageId};
use guppy::{CargoMetadata, Error, PackageId, graph::DependencyDirection};
use std::iter;

fn main() -> Result<(), Error> {
Expand Down
2 changes: 1 addition & 1 deletion guppy/examples/print_by_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use guppy::{CargoMetadata, Error};
use std::{
collections::BTreeMap,
io::{stdout, Write},
io::{Write, stdout},
};

fn main() -> Result<(), Error> {
Expand Down
2 changes: 1 addition & 1 deletion guppy/examples/print_dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
//! ```
use guppy::{
graph::{DotWrite, PackageDotVisitor, PackageLink, PackageMetadata},
CargoMetadata, Error,
graph::{DotWrite, PackageDotVisitor, PackageLink, PackageMetadata},
};
use std::fmt;

Expand Down
2 changes: 1 addition & 1 deletion guppy/examples/remove_dev_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//! to filter out those links.
use guppy::{
graph::{DependencyDirection, PackageLink},
CargoMetadata, Error,
graph::{DependencyDirection, PackageLink},
};
use std::iter;

Expand Down
2 changes: 1 addition & 1 deletion guppy/examples/topo_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! The into_iter_ids and into_iter_metadatas iterators return packages in topological order. Note
//! that into_iter_links returns links in "link order" -- see its documentation for more.
use guppy::{graph::DependencyDirection, CargoMetadata, Error};
use guppy::{CargoMetadata, Error, graph::DependencyDirection};

fn main() -> Result<(), Error> {
// `guppy` accepts `cargo metadata` JSON output. Use a pre-existing fixture for these examples.
Expand Down
4 changes: 2 additions & 2 deletions guppy/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

//! Contains types that describe errors and warnings that `guppy` methods can return.
use crate::{graph::feature::FeatureId, PackageId};
use crate::{PackageId, graph::feature::FeatureId};
use Error::*;
use camino::Utf8PathBuf;
use std::{error, fmt};
pub use target_spec::Error as TargetSpecError;
use Error::*;

/// Error type describing the sorts of errors `guppy` can return.
#[derive(Debug)]
Expand Down
10 changes: 5 additions & 5 deletions guppy/src/graph/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::{
Error, PackageId,
graph::{
cargo_version_matches, BuildTargetImpl, BuildTargetKindImpl, DepRequiredOrOptional,
DependencyReqImpl, NamedFeatureDep, OwnedBuildTargetId, PackageGraph, PackageGraphData,
PackageIx, PackageLinkImpl, PackageMetadataImpl, PackagePublishImpl, PackageSourceImpl,
WorkspaceImpl,
BuildTargetImpl, BuildTargetKindImpl, DepRequiredOrOptional, DependencyReqImpl,
NamedFeatureDep, OwnedBuildTargetId, PackageGraph, PackageGraphData, PackageIx,
PackageLinkImpl, PackageMetadataImpl, PackagePublishImpl, PackageSourceImpl, WorkspaceImpl,
cargo_version_matches,
},
sorted_set::SortedSet,
Error, PackageId,
};
use ahash::AHashMap;
use camino::{Utf8Path, Utf8PathBuf};
Expand Down
4 changes: 2 additions & 2 deletions guppy/src/graph/cargo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::{
DependencyKind, Error,
graph::{
DependencyDirection, PackageGraph, PackageIx, PackageLink, PackageSet,
cargo::{
CargoIntermediateSet, CargoOptions, CargoResolverVersion, CargoSet, InitialsPlatform,
},
feature::{ConditionalLink, FeatureLabel, FeatureQuery, FeatureSet, StandardFeatures},
DependencyDirection, PackageGraph, PackageIx, PackageLink, PackageSet,
},
platform::{EnabledTernary, PlatformSpec},
sorted_set::SortedSet,
DependencyKind, Error,
};
use fixedbitset::FixedBitSet;
use petgraph::{prelude::*, visit::VisitMap};
Expand Down
4 changes: 2 additions & 2 deletions guppy/src/graph/cargo/cargo_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::{
Error, PackageId,
graph::{
DependencyDirection, PackageGraph, PackageIx, PackageLink, PackageSet,
cargo::build::CargoSetBuildState,
feature::{FeatureGraph, FeatureSet},
DependencyDirection, PackageGraph, PackageIx, PackageLink, PackageSet,
},
platform::PlatformSpec,
sorted_set::SortedSet,
Error, PackageId,
};
use petgraph::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion guppy/src/graph/cycles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//! See [`Cycles`][] for detailed docs.
use crate::{
Error, PackageId,
graph::{PackageGraph, PackageIx},
petgraph_support::scc::Sccs,
Error, PackageId,
};

/// Contains information about dependency cycles.
Expand Down
4 changes: 2 additions & 2 deletions guppy/src/graph/feature/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
use crate::{
errors::{FeatureBuildStage, FeatureGraphWarning},
graph::{
DepRequiredOrOptional, DependencyReq, FeatureIndexInPackage, FeatureIx, NamedFeatureDep,
PackageGraph, PackageIx, PackageLink, PackageMetadata,
feature::{
ConditionalLinkImpl, FeatureEdge, FeatureGraphImpl, FeatureLabel, FeatureMetadataImpl,
FeatureNode, WeakDependencies, WeakIndex,
},
DepRequiredOrOptional, DependencyReq, FeatureIndexInPackage, FeatureIx, NamedFeatureDep,
PackageGraph, PackageIx, PackageLink, PackageMetadata,
},
platform::PlatformStatusImpl,
};
Expand Down
4 changes: 2 additions & 2 deletions guppy/src/graph/feature/cycles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
//! Code for handling cycles in feature graphs.
use crate::{
Error,
graph::{
feature::{FeatureGraph, FeatureId},
FeatureIx,
feature::{FeatureGraph, FeatureId},
},
petgraph_support::scc::Sccs,
Error,
};

/// Contains information about dependency cycles in feature graphs.
Expand Down
Loading

0 comments on commit 4722ab3

Please sign in to comment.