Fix warnings triggered by elided_named_lifetimes lint (#15328)

# Objective

Eliminate some warnings introduced by the new rust lint
[elided_named_lifetimes](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/builtin/static.ELIDED_NAMED_LIFETIMES.html),
fix #15326.

## Solution

- Add or remove lifetime markers to not trigger the lint.

## Testing

- When the lint comes to stable, the CI will fail and this PR could fix
that.
This commit is contained in:
VitalyR 2024-09-21 03:17:33 +08:00 committed by GitHub
parent fd329c0426
commit 661ab1ab41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 59 additions and 41 deletions

View File

@ -190,32 +190,35 @@ pub trait ErasedAssetReader: Send + Sync + 'static {
fn read<'a>( fn read<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<dyn Reader + 'a>, AssetReaderError>>; ) -> BoxedFuture<'a, Result<Box<dyn Reader + 'a>, AssetReaderError>>;
/// Returns a future to load the full file data at the provided path. /// Returns a future to load the full file data at the provided path.
fn read_meta<'a>( fn read_meta<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<dyn Reader + 'a>, AssetReaderError>>; ) -> BoxedFuture<'a, Result<Box<dyn Reader + 'a>, AssetReaderError>>;
/// Returns an iterator of directory entry names at the provided path. /// Returns an iterator of directory entry names at the provided path.
fn read_directory<'a>( fn read_directory<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<PathStream>, AssetReaderError>>; ) -> BoxedFuture<'a, Result<Box<PathStream>, AssetReaderError>>;
/// Returns true if the provided path points to a directory. /// Returns true if the provided path points to a directory.
fn is_directory<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<bool, AssetReaderError>>; fn is_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<'a, Result<bool, AssetReaderError>>;
/// Reads asset metadata bytes at the given `path` into a [`Vec<u8>`]. This is a convenience /// Reads asset metadata bytes at the given `path` into a [`Vec<u8>`]. This is a convenience
/// function that wraps [`ErasedAssetReader::read_meta`] by default. /// function that wraps [`ErasedAssetReader::read_meta`] by default.
fn read_meta_bytes<'a>( fn read_meta_bytes<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Vec<u8>, AssetReaderError>>; ) -> BoxedFuture<'a, Result<Vec<u8>, AssetReaderError>>;
} }
impl<T: AssetReader> ErasedAssetReader for T { impl<T: AssetReader> ErasedAssetReader for T {
fn read<'a>( fn read<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<dyn Reader + 'a>, AssetReaderError>> { ) -> BoxedFuture<'a, Result<Box<dyn Reader + 'a>, AssetReaderError>> {
Box::pin(async { Box::pin(async {
let reader = Self::read(self, path).await?; let reader = Self::read(self, path).await?;
Ok(Box::new(reader) as Box<dyn Reader>) Ok(Box::new(reader) as Box<dyn Reader>)
@ -224,7 +227,7 @@ impl<T: AssetReader> ErasedAssetReader for T {
fn read_meta<'a>( fn read_meta<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<dyn Reader + 'a>, AssetReaderError>> { ) -> BoxedFuture<'a, Result<Box<dyn Reader + 'a>, AssetReaderError>> {
Box::pin(async { Box::pin(async {
let reader = Self::read_meta(self, path).await?; let reader = Self::read_meta(self, path).await?;
Ok(Box::new(reader) as Box<dyn Reader>) Ok(Box::new(reader) as Box<dyn Reader>)
@ -233,16 +236,19 @@ impl<T: AssetReader> ErasedAssetReader for T {
fn read_directory<'a>( fn read_directory<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<PathStream>, AssetReaderError>> { ) -> BoxedFuture<'a, Result<Box<PathStream>, AssetReaderError>> {
Box::pin(Self::read_directory(self, path)) Box::pin(Self::read_directory(self, path))
} }
fn is_directory<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<bool, AssetReaderError>> { fn is_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<'a, Result<bool, AssetReaderError>> {
Box::pin(Self::is_directory(self, path)) Box::pin(Self::is_directory(self, path))
} }
fn read_meta_bytes<'a>( fn read_meta_bytes<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Vec<u8>, AssetReaderError>> { ) -> BoxedFuture<'a, Result<Vec<u8>, AssetReaderError>> {
Box::pin(Self::read_meta_bytes(self, path)) Box::pin(Self::read_meta_bytes(self, path))
} }
} }
@ -351,115 +357,127 @@ pub trait AssetWriter: Send + Sync + 'static {
/// as [`AssetWriter`] isn't currently object safe. /// as [`AssetWriter`] isn't currently object safe.
pub trait ErasedAssetWriter: Send + Sync + 'static { pub trait ErasedAssetWriter: Send + Sync + 'static {
/// Writes the full asset bytes at the provided path. /// Writes the full asset bytes at the provided path.
fn write<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<Box<Writer>, AssetWriterError>>; fn write<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<'a, Result<Box<Writer>, AssetWriterError>>;
/// Writes the full asset meta bytes at the provided path. /// Writes the full asset meta bytes at the provided path.
/// This _should not_ include storage specific extensions like `.meta`. /// This _should not_ include storage specific extensions like `.meta`.
fn write_meta<'a>( fn write_meta<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<Writer>, AssetWriterError>>; ) -> BoxedFuture<'a, Result<Box<Writer>, AssetWriterError>>;
/// Removes the asset stored at the given path. /// Removes the asset stored at the given path.
fn remove<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<(), AssetWriterError>>; fn remove<'a>(&'a self, path: &'a Path) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Removes the asset meta stored at the given path. /// Removes the asset meta stored at the given path.
/// This _should not_ include storage specific extensions like `.meta`. /// This _should not_ include storage specific extensions like `.meta`.
fn remove_meta<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<(), AssetWriterError>>; fn remove_meta<'a>(&'a self, path: &'a Path) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Renames the asset at `old_path` to `new_path` /// Renames the asset at `old_path` to `new_path`
fn rename<'a>( fn rename<'a>(
&'a self, &'a self,
old_path: &'a Path, old_path: &'a Path,
new_path: &'a Path, new_path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>>; ) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Renames the asset meta for the asset at `old_path` to `new_path`. /// Renames the asset meta for the asset at `old_path` to `new_path`.
/// This _should not_ include storage specific extensions like `.meta`. /// This _should not_ include storage specific extensions like `.meta`.
fn rename_meta<'a>( fn rename_meta<'a>(
&'a self, &'a self,
old_path: &'a Path, old_path: &'a Path,
new_path: &'a Path, new_path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>>; ) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Removes the directory at the given path, including all assets _and_ directories in that directory. /// Removes the directory at the given path, including all assets _and_ directories in that directory.
fn remove_directory<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<(), AssetWriterError>>; fn remove_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Removes the directory at the given path, but only if it is completely empty. This will return an error if the /// Removes the directory at the given path, but only if it is completely empty. This will return an error if the
/// directory is not empty. /// directory is not empty.
fn remove_empty_directory<'a>( fn remove_empty_directory<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>>; ) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Removes all assets (and directories) in this directory, resulting in an empty directory. /// Removes all assets (and directories) in this directory, resulting in an empty directory.
fn remove_assets_in_directory<'a>( fn remove_assets_in_directory<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>>; ) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Writes the asset `bytes` to the given `path`. /// Writes the asset `bytes` to the given `path`.
fn write_bytes<'a>( fn write_bytes<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
bytes: &'a [u8], bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>>; ) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Writes the asset meta `bytes` to the given `path`. /// Writes the asset meta `bytes` to the given `path`.
fn write_meta_bytes<'a>( fn write_meta_bytes<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
bytes: &'a [u8], bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>>; ) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
} }
impl<T: AssetWriter> ErasedAssetWriter for T { impl<T: AssetWriter> ErasedAssetWriter for T {
fn write<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<Box<Writer>, AssetWriterError>> { fn write<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<'a, Result<Box<Writer>, AssetWriterError>> {
Box::pin(Self::write(self, path)) Box::pin(Self::write(self, path))
} }
fn write_meta<'a>( fn write_meta<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<Box<Writer>, AssetWriterError>> { ) -> BoxedFuture<'a, Result<Box<Writer>, AssetWriterError>> {
Box::pin(Self::write_meta(self, path)) Box::pin(Self::write_meta(self, path))
} }
fn remove<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<(), AssetWriterError>> { fn remove<'a>(&'a self, path: &'a Path) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::remove(self, path)) Box::pin(Self::remove(self, path))
} }
fn remove_meta<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<(), AssetWriterError>> { fn remove_meta<'a>(&'a self, path: &'a Path) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::remove_meta(self, path)) Box::pin(Self::remove_meta(self, path))
} }
fn rename<'a>( fn rename<'a>(
&'a self, &'a self,
old_path: &'a Path, old_path: &'a Path,
new_path: &'a Path, new_path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> { ) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::rename(self, old_path, new_path)) Box::pin(Self::rename(self, old_path, new_path))
} }
fn rename_meta<'a>( fn rename_meta<'a>(
&'a self, &'a self,
old_path: &'a Path, old_path: &'a Path,
new_path: &'a Path, new_path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> { ) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::rename_meta(self, old_path, new_path)) Box::pin(Self::rename_meta(self, old_path, new_path))
} }
fn remove_directory<'a>(&'a self, path: &'a Path) -> BoxedFuture<Result<(), AssetWriterError>> { fn remove_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::remove_directory(self, path)) Box::pin(Self::remove_directory(self, path))
} }
fn remove_empty_directory<'a>( fn remove_empty_directory<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> { ) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::remove_empty_directory(self, path)) Box::pin(Self::remove_empty_directory(self, path))
} }
fn remove_assets_in_directory<'a>( fn remove_assets_in_directory<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> { ) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::remove_assets_in_directory(self, path)) Box::pin(Self::remove_assets_in_directory(self, path))
} }
fn write_bytes<'a>( fn write_bytes<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
bytes: &'a [u8], bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>> { ) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::write_bytes(self, path, bytes)) Box::pin(Self::write_bytes(self, path, bytes))
} }
fn write_meta_bytes<'a>( fn write_meta_bytes<'a>(
&'a self, &'a self,
path: &'a Path, path: &'a Path,
bytes: &'a [u8], bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>> { ) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::write_meta_bytes(self, path, bytes)) Box::pin(Self::write_meta_bytes(self, path, bytes))
} }
} }

View File

@ -360,10 +360,10 @@ pub struct ArrayIter<'a> {
index: usize, index: usize,
} }
impl<'a> ArrayIter<'a> { impl ArrayIter<'_> {
/// Creates a new [`ArrayIter`]. /// Creates a new [`ArrayIter`].
#[inline] #[inline]
pub const fn new(array: &'a dyn Array) -> ArrayIter { pub const fn new(array: &dyn Array) -> ArrayIter {
ArrayIter { array, index: 0 } ArrayIter { array, index: 0 }
} }
} }

View File

@ -381,10 +381,10 @@ pub struct ListIter<'a> {
index: usize, index: usize,
} }
impl<'a> ListIter<'a> { impl ListIter<'_> {
/// Creates a new [`ListIter`]. /// Creates a new [`ListIter`].
#[inline] #[inline]
pub const fn new(list: &'a dyn List) -> ListIter { pub const fn new(list: &dyn List) -> ListIter {
ListIter { list, index: 0 } ListIter { list, index: 0 }
} }
} }
@ -406,7 +406,7 @@ impl<'a> Iterator for ListIter<'a> {
} }
} }
impl<'a> ExactSizeIterator for ListIter<'a> {} impl ExactSizeIterator for ListIter<'_> {}
/// Returns the `u64` hash of the given [list](List). /// Returns the `u64` hash of the given [list](List).
#[inline] #[inline]

View File

@ -403,10 +403,10 @@ pub struct MapIter<'a> {
index: usize, index: usize,
} }
impl<'a> MapIter<'a> { impl MapIter<'_> {
/// Creates a new [`MapIter`]. /// Creates a new [`MapIter`].
#[inline] #[inline]
pub const fn new(map: &'a dyn Map) -> MapIter { pub const fn new(map: &dyn Map) -> MapIter {
MapIter { map, index: 0 } MapIter { map, index: 0 }
} }
} }

View File

@ -421,7 +421,7 @@ impl ParsedPath {
/// Similar to [`Self::parse`] but only works on `&'static str` /// Similar to [`Self::parse`] but only works on `&'static str`
/// and does not allocate per named field. /// and does not allocate per named field.
pub fn parse_static(string: &'static str) -> PathResult<Self> { pub fn parse_static(string: &'static str) -> PathResult<'static, Self> {
let mut parts = Vec::new(); let mut parts = Vec::new();
for (access, offset) in PathParser::new(string) { for (access, offset) in PathParser::new(string) {
parts.push(OffsetAccess { parts.push(OffsetAccess {

View File

@ -578,7 +578,7 @@ pub trait FromType<T> {
/// [`FromType::from_type`]. /// [`FromType::from_type`].
#[derive(Clone)] #[derive(Clone)]
pub struct ReflectSerialize { pub struct ReflectSerialize {
get_serializable: for<'a> fn(value: &'a dyn Reflect) -> Serializable, get_serializable: fn(value: &dyn Reflect) -> Serializable,
} }
impl<T: TypePath + FromReflect + erased_serde::Serialize> FromType<T> for ReflectSerialize { impl<T: TypePath + FromReflect + erased_serde::Serialize> FromType<T> for ReflectSerialize {