Skip to content

Commit

Permalink
Fix clippy warnings after rust update (#1790)
Browse files Browse the repository at this point in the history
- **Clippy --fix**
- **Elided lifetime has a name**
  • Loading branch information
maciektr authored Nov 28, 2024
1 parent 121696d commit df5aef6
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl MarkdownDocItem for Trait {
/// cthat share the same name.
pub fn mark_duplicated_item_with_relative_path<'a, T: TopLevelMarkdownDocItem + 'a>(
items: &'a [&'a T],
) -> Vec<(&&'a T, Option<String>)> {
) -> Vec<(&'a &'a T, Option<String>)> {
let mut paths_for_item_name = HashMap::<String, Vec<String>>::new();
for item in items {
paths_for_item_name
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl FromStr for Checksum {
}
}

impl<'a> TryFrom<&'a str> for Checksum {
impl TryFrom<&str> for Checksum {
type Error = anyhow::Error;

fn try_from(s: &str) -> Result<Self, Self::Error> {
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Config {
self.creation_time.elapsed()
}

pub fn package_cache_lock<'a>(&'a self) -> &AdvisoryLock<'a> {
pub fn package_cache_lock<'a>(&'a self) -> &'a AdvisoryLock<'a> {
// UNSAFE: These mem::transmute calls only change generic lifetime parameters.
let static_al: &AdvisoryLock<'static> = self.package_cache_lock.get_or_init(|| {
let not_static_al =
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/registry/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<'a> RegistryCache<'a> {
}

#[async_trait(?Send)]
impl<'c> Registry for RegistryCache<'c> {
impl Registry for RegistryCache<'_> {
/// Attempt to find the packages that match dependency request.
async fn query(&self, dependency: &ManifestDependency) -> Result<Vec<Summary>> {
self.queries.load(dependency.clone()).await
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/registry/client/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'c> HttpRegistryClient<'c> {
}

#[async_trait]
impl<'c> RegistryClient for HttpRegistryClient<'c> {
impl RegistryClient for HttpRegistryClient<'_> {
async fn get_records(
&self,
package: PackageName,
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/registry/patcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'a> RegistryPatcher<'a> {
}

#[async_trait(?Send)]
impl<'a> Registry for RegistryPatcher<'a> {
impl Registry for RegistryPatcher<'_> {
#[tracing::instrument(skip_all)]
async fn query(&self, dependency: &ManifestDependency) -> Result<Vec<Summary>> {
let patch = self.patch_map.lookup(dependency);
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/registry/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'c> SourceMap<'c> {
}

#[async_trait(?Send)]
impl<'c> Registry for SourceMap<'c> {
impl Registry for SourceMap<'_> {
/// Attempt to find the packages that match a dependency request.
async fn query(&self, dependency: &ManifestDependency) -> Result<Vec<Summary>> {
let source = self.ensure_loaded(dependency.source_id).await?;
Expand Down
6 changes: 3 additions & 3 deletions scarb/src/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn check_unique_targets(targets: &Vec<&Target>) -> Result<()> {
Ok(())
}

impl<'c> fmt::Display for Workspace<'c> {
impl fmt::Display for Workspace<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let manifest_path = self.manifest_path();
let path = if manifest_path.file_name() == Some(MANIFEST_FILE_NAME) {
Expand All @@ -233,7 +233,7 @@ impl<'c> fmt::Display for Workspace<'c> {
}
}

impl<'c> fmt::Debug for Workspace<'c> {
impl fmt::Debug for Workspace<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Workspace")
.field("members", &self.members)
Expand All @@ -251,7 +251,7 @@ impl Utf8PathWorkspaceExt for Utf8Path {
}
}

impl<'c> PackagesSource for Workspace<'c> {
impl PackagesSource for Workspace<'_> {
type Package = Package;

fn package_name_of(package: &Self::Package) -> &str {
Expand Down
6 changes: 3 additions & 3 deletions scarb/src/internal/to_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ impl ToVersion for Version {
}
}

impl<'a> ToVersion for &'a str {
impl ToVersion for &str {
fn to_version(self) -> Result<Version> {
Version::parse(self.trim())
.map_err(|_| anyhow::format_err!("cannot parse '{}' as a semver", self))
}
}

impl<'a> ToVersion for &'a String {
impl ToVersion for &String {
fn to_version(self) -> Result<Version> {
(**self).to_version()
}
}

impl<'a> ToVersion for &'a Version {
impl ToVersion for &Version {
fn to_version(self) -> Result<Version> {
Ok(self.clone())
}
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/ops/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn format_file_in_place(
}
}

impl<'t> ParallelVisitor for PathFormatter<'t> {
impl ParallelVisitor for PathFormatter<'_> {
fn visit(&mut self, dir_entry_res: Result<DirEntry, Error>) -> WalkState {
let dir_entry = if let Ok(dir_entry) = dir_entry_res {
dir_entry
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn shlex_join(cmd: &Command) -> String {

struct ShlexJoin<'a>(&'a Command);

impl<'a> fmt::Display for ShlexJoin<'a> {
impl fmt::Display for ShlexJoin<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn write_quoted(f: &mut fmt::Formatter<'_>, s: &OsStr) -> fmt::Result {
let utf = s.to_string_lossy();
Expand Down
4 changes: 2 additions & 2 deletions scarb/src/sources/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl<'c> GitSource<'c> {
}

#[async_trait]
impl<'c> Source for GitSource<'c> {
impl Source for GitSource<'_> {
async fn query(&self, dependency: &ManifestDependency) -> Result<Vec<Summary>> {
self.ensure_loaded()
.await?
Expand All @@ -164,7 +164,7 @@ impl<'c> Source for GitSource<'c> {
}
}

impl<'c> fmt::Debug for GitSource<'c> {
impl fmt::Debug for GitSource<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("GitSource")
.field("source", &self.source_id.to_string())
Expand Down
4 changes: 2 additions & 2 deletions scarb/src/sources/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'c> PathSource<'c> {
}

#[async_trait]
impl<'c> Source for PathSource<'c> {
impl Source for PathSource<'_> {
#[tracing::instrument(level = "trace", skip(self))]
async fn query(&self, dependency: &ManifestDependency) -> Result<Vec<Summary>> {
Ok(self
Expand All @@ -114,7 +114,7 @@ impl<'c> Source for PathSource<'c> {
}
}

impl<'c> fmt::Debug for PathSource<'c> {
impl fmt::Debug for PathSource<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PathSource")
.field("source", &self.source_id.to_string())
Expand Down
4 changes: 2 additions & 2 deletions scarb/src/sources/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<'c> RegistrySource<'c> {
}

#[async_trait]
impl<'c> Source for RegistrySource<'c> {
impl Source for RegistrySource<'_> {
#[tracing::instrument(level = "trace", skip(self))]
async fn query(&self, dependency: &ManifestDependency) -> Result<Vec<Summary>> {
let records = self
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<'c> RegistrySource<'c> {
}
}

impl<'c> fmt::Debug for RegistrySource<'c> {
impl fmt::Debug for RegistrySource<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RegistrySource")
.field("source", &self.source_id.to_string())
Expand Down
4 changes: 2 additions & 2 deletions scarb/src/sources/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'c> StandardLibSource<'c> {
}

#[async_trait]
impl<'c> Source for StandardLibSource<'c> {
impl Source for StandardLibSource<'_> {
#[tracing::instrument(level = "trace", skip(self))]
async fn query(&self, dependency: &ManifestDependency) -> Result<Vec<Summary>> {
self.ensure_loaded().await?.query(dependency).await
Expand All @@ -88,7 +88,7 @@ impl<'c> Source for StandardLibSource<'c> {
}
}

impl<'c> fmt::Debug for StandardLibSource<'c> {
impl fmt::Debug for StandardLibSource<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("StandardLibSource").finish_non_exhaustive()
}
Expand Down
2 changes: 1 addition & 1 deletion utils/scarb-test-support/src/project_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub struct DepWith<'a, T: DepBuilder + ?Sized> {
value: Value,
}

impl<'a, T: DepBuilder + ?Sized> DepBuilder for DepWith<'a, T> {
impl<T: DepBuilder + ?Sized> DepBuilder for DepWith<'_, T> {
fn build(&self) -> Value {
let mut table = self.dep.build();
table
Expand Down
2 changes: 1 addition & 1 deletion utils/scarb-ui/src/args/packages_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<'a> Spec<'a> {
}
}

impl<'a> fmt::Display for Spec<'a> {
impl fmt::Display for Spec<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Spec::All => write!(f, "*"),
Expand Down
2 changes: 1 addition & 1 deletion utils/scarb-ui/src/components/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a> Status<'a> {
}
}

impl<'a> Message for Status<'a> {
impl Message for Status<'_> {
fn text(self) -> String {
format!(
"{} {}",
Expand Down
2 changes: 1 addition & 1 deletion utils/scarb-ui/src/components/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'a> TypedMessage<'a> {
}
}

impl<'a> Message for TypedMessage<'a> {
impl Message for TypedMessage<'_> {
fn text(self) -> String {
if self.skip_type_for_text {
self.message.to_string()
Expand Down
2 changes: 1 addition & 1 deletion utils/scarb-ui/src/components/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'a, T> ValueMessage<'a, T> {
}
}

impl<'a, T> Message for ValueMessage<'a, T>
impl<T> Message for ValueMessage<'_, T>
where
T: Display + Serialize,
{
Expand Down

0 comments on commit df5aef6

Please sign in to comment.