Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings triggered by elided_named_lifetimes lint #15328

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 50 additions & 32 deletions crates/bevy_asset/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,32 +190,35 @@ pub trait ErasedAssetReader: Send + Sync + 'static {
fn read<'a>(
&'a self,
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.
fn read_meta<'a>(
&'a self,
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.
fn read_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Box<PathStream>, AssetReaderError>>;
) -> BoxedFuture<'a, Result<Box<PathStream>, AssetReaderError>>;
/// 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
/// function that wraps [`ErasedAssetReader::read_meta`] by default.
fn read_meta_bytes<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Vec<u8>, AssetReaderError>>;
) -> BoxedFuture<'a, Result<Vec<u8>, AssetReaderError>>;
}

impl<T: AssetReader> ErasedAssetReader for T {
fn read<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Box<dyn Reader + 'a>, AssetReaderError>> {
) -> BoxedFuture<'a, Result<Box<dyn Reader + 'a>, AssetReaderError>> {
Box::pin(async {
let reader = Self::read(self, path).await?;
Ok(Box::new(reader) as Box<dyn Reader>)
Expand All @@ -224,7 +227,7 @@ impl<T: AssetReader> ErasedAssetReader for T {
fn read_meta<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Box<dyn Reader + 'a>, AssetReaderError>> {
) -> BoxedFuture<'a, Result<Box<dyn Reader + 'a>, AssetReaderError>> {
Box::pin(async {
let reader = Self::read_meta(self, path).await?;
Ok(Box::new(reader) as Box<dyn Reader>)
Expand All @@ -233,16 +236,19 @@ impl<T: AssetReader> ErasedAssetReader for T {
fn read_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Box<PathStream>, AssetReaderError>> {
) -> BoxedFuture<'a, Result<Box<PathStream>, AssetReaderError>> {
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))
}
fn read_meta_bytes<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Vec<u8>, AssetReaderError>> {
) -> BoxedFuture<'a, Result<Vec<u8>, AssetReaderError>> {
Box::pin(Self::read_meta_bytes(self, path))
}
}
Expand Down Expand Up @@ -351,115 +357,127 @@ pub trait AssetWriter: Send + Sync + 'static {
/// as [`AssetWriter`] isn't currently object safe.
pub trait ErasedAssetWriter: Send + Sync + 'static {
/// 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.
/// This _should not_ include storage specific extensions like `.meta`.
fn write_meta<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Box<Writer>, AssetWriterError>>;
) -> BoxedFuture<'a, Result<Box<Writer>, AssetWriterError>>;
/// 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.
/// 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`
fn rename<'a>(
&'a self,
old_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`.
/// This _should not_ include storage specific extensions like `.meta`.
fn rename_meta<'a>(
&'a self,
old_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.
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
/// directory is not empty.
fn remove_empty_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>>;
) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Removes all assets (and directories) in this directory, resulting in an empty directory.
fn remove_assets_in_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>>;
) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Writes the asset `bytes` to the given `path`.
fn write_bytes<'a>(
&'a self,
path: &'a Path,
bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>>;
) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
/// Writes the asset meta `bytes` to the given `path`.
fn write_meta_bytes<'a>(
&'a self,
path: &'a Path,
bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>>;
) -> BoxedFuture<'a, Result<(), AssetWriterError>>;
}

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))
}
fn write_meta<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<Box<Writer>, AssetWriterError>> {
) -> BoxedFuture<'a, Result<Box<Writer>, AssetWriterError>> {
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))
}
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))
}
fn rename<'a>(
&'a self,
old_path: &'a Path,
new_path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> {
) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::rename(self, old_path, new_path))
}
fn rename_meta<'a>(
&'a self,
old_path: &'a Path,
new_path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> {
) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
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))
}
fn remove_empty_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> {
) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::remove_empty_directory(self, path))
}
fn remove_assets_in_directory<'a>(
&'a self,
path: &'a Path,
) -> BoxedFuture<Result<(), AssetWriterError>> {
) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::remove_assets_in_directory(self, path))
}
fn write_bytes<'a>(
&'a self,
path: &'a Path,
bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>> {
) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::write_bytes(self, path, bytes))
}
fn write_meta_bytes<'a>(
&'a self,
path: &'a Path,
bytes: &'a [u8],
) -> BoxedFuture<Result<(), AssetWriterError>> {
) -> BoxedFuture<'a, Result<(), AssetWriterError>> {
Box::pin(Self::write_meta_bytes(self, path, bytes))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ impl ScheduleGraph {
&'a self,
ambiguities: &'a [(NodeId, NodeId, Vec<ComponentId>)],
components: &'a Components,
) -> impl Iterator<Item = (String, String, Vec<&str>)> + 'a {
) -> impl Iterator<Item = (String, String, Vec<&'a str>)> + 'a {
ambiguities
.iter()
.map(move |(system_a, system_b, conflicts)| {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ pub struct ArrayIter<'a> {
index: usize,
}

impl<'a> ArrayIter<'a> {
impl ArrayIter<'_> {
/// Creates a new [`ArrayIter`].
#[inline]
pub const fn new(array: &'a dyn Array) -> ArrayIter {
pub const fn new(array: &dyn Array) -> ArrayIter {
ArrayIter { array, index: 0 }
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_reflect/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@ pub struct ListIter<'a> {
index: usize,
}

impl<'a> ListIter<'a> {
impl ListIter<'_> {
/// Creates a new [`ListIter`].
#[inline]
pub const fn new(list: &'a dyn List) -> ListIter {
pub const fn new(list: &dyn List) -> ListIter {
ListIter { list, index: 0 }
}
}
Expand All @@ -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).
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,10 @@ pub struct MapIter<'a> {
index: usize,
}

impl<'a> MapIter<'a> {
impl MapIter<'_> {
/// Creates a new [`MapIter`].
#[inline]
pub const fn new(map: &'a dyn Map) -> MapIter {
pub const fn new(map: &dyn Map) -> MapIter {
MapIter { map, index: 0 }
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl ParsedPath {

/// Similar to [`Self::parse`] but only works on `&'static str`
/// 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();
for (access, offset) in PathParser::new(string) {
parts.push(OffsetAccess {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/src/type_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ pub trait FromType<T> {
/// [`FromType::from_type`].
#[derive(Clone)]
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 {
Expand Down