diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eefc25b..6ff7f06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,20 +59,21 @@ jobs: command: test args: --verbose - miri: - name: "Miri" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install Miri - run: | - rustup toolchain install nightly --component miri - rustup override set nightly - cargo miri setup - - name: Test with Miri - # Miri currently reports leaks in some tests so we disable that check - # here (might be due to ptr-int-ptr in crossbeam-epoch so might be - # resolved in future versions of that crate). - # - # crossbeam-epoch doesn't pass with stacked borrows https://github.com/crossbeam-rs/crossbeam/issues/545 - run: MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-tree-borrows" cargo miri test + # Can't run miri right now https://github.com/crossbeam-rs/crossbeam/issues/1181 + #miri: + # name: "Miri" + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - name: Install Miri + # run: | + # rustup toolchain install nightly --component miri + # rustup override set nightly + # cargo miri setup + # - name: Test with Miri + # # Miri currently reports leaks in some tests so we disable that check + # # here (might be due to ptr-int-ptr in crossbeam-epoch so might be + # # resolved in future versions of that crate). + # # + # # crossbeam-epoch doesn't pass with stacked borrows https://github.com/crossbeam-rs/crossbeam/issues/545 + # run: MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-tree-borrows" cargo miri test diff --git a/README.md b/README.md index 94a0ce4..85bd8a7 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Please see [the benchmark](benches/bench.rs) for a bigger (and useful) example. ### Required Rust version -`1.56.1 stable` +`1.65.0 stable` ## Features diff --git a/benches/bench.rs b/benches/bench.rs index ccb4508..b41c440 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -6,7 +6,7 @@ use std::ops::{Index, IndexMut}; use cgmath::Vector3; use shred::*; -use test::{black_box, Bencher}; +use test::{Bencher, black_box}; #[derive(Debug)] struct VecStorage { diff --git a/examples/async.rs b/examples/async.rs index d123c18..cf26d64 100644 --- a/examples/async.rs +++ b/examples/async.rs @@ -14,6 +14,7 @@ struct Data<'a> { b: Write<'a, ResB>, } +#[allow(dead_code)] struct EmptySystem(*mut i8); // System is not thread-safe impl<'a> System<'a> for EmptySystem { diff --git a/examples/batch_dispatching.rs b/examples/batch_dispatching.rs index eeb251c..d5b7867 100644 --- a/examples/batch_dispatching.rs +++ b/examples/batch_dispatching.rs @@ -53,13 +53,14 @@ fn main() { // Resources #[derive(Default)] +#[allow(dead_code)] pub struct PotatoStore(i32); #[derive(Default)] +#[allow(dead_code)] pub struct TomatoStore(f32); /// System that says "Hello!" - pub struct SayHelloSystem; impl<'a> System<'a> for SayHelloSystem { @@ -71,7 +72,6 @@ impl<'a> System<'a> for SayHelloSystem { } /// System that says "Buy Potato" - pub struct BuyPotatoSystem; impl<'a> System<'a> for BuyPotatoSystem { @@ -83,7 +83,6 @@ impl<'a> System<'a> for BuyPotatoSystem { } /// System that says "Buy Tomato" - pub struct BuyTomatoSystem; impl<'a> System<'a> for BuyTomatoSystem { diff --git a/examples/dyn_sys_data.rs b/examples/dyn_sys_data.rs index a5bacea..b383578 100644 --- a/examples/dyn_sys_data.rs +++ b/examples/dyn_sys_data.rs @@ -4,6 +4,7 @@ //! language. //! //! It does that by implementing `DynamicSystemData` and using `MetaTable`. +#![allow(clippy::disallowed_names)] extern crate shred; @@ -11,9 +12,9 @@ extern crate shred; use ahash::AHashMap as HashMap; use shred::{ - cell::{AtomicRef, AtomicRefMut}, Accessor, AccessorCow, CastFrom, DispatcherBuilder, DynamicSystemData, MetaTable, Read, Resource, ResourceId, System, SystemData, World, + cell::{AtomicRef, AtomicRefMut}, }; struct Dependencies { @@ -188,8 +189,8 @@ fn create_script_sys(res: &World) -> DynamicSystem { input.writes[0].call_method("foo"); } - let reads = vec!["Bar"]; - let writes = vec!["Foo"]; + let reads = ["Bar"]; + let writes = ["Foo"]; // -- how we create the system -- let table = res.fetch::(); diff --git a/examples/multi_batch_dispatching.rs b/examples/multi_batch_dispatching.rs index 98ec66a..da918bc 100644 --- a/examples/multi_batch_dispatching.rs +++ b/examples/multi_batch_dispatching.rs @@ -53,13 +53,14 @@ fn main() { // Resources #[derive(Default)] +#[allow(dead_code)] pub struct PotatoStore(i32); #[derive(Default)] +#[allow(dead_code)] pub struct TomatoStore(f32); /// System that says "Hello!" - pub struct SayHelloSystem; impl<'a> System<'a> for SayHelloSystem { @@ -71,7 +72,6 @@ impl<'a> System<'a> for SayHelloSystem { } /// System that says "Buy Potato" - pub struct BuyPotatoSystem; impl<'a> System<'a> for BuyPotatoSystem { @@ -83,7 +83,6 @@ impl<'a> System<'a> for BuyPotatoSystem { } /// System that says "Buy Tomato" - pub struct BuyTomatoSystem; impl<'a> System<'a> for BuyTomatoSystem { diff --git a/examples/par_seq.rs b/examples/par_seq.rs index 3e4ca74..ee70a3b 100644 --- a/examples/par_seq.rs +++ b/examples/par_seq.rs @@ -23,12 +23,14 @@ struct SysA; struct SysB; struct SysC; struct SysD; +#[allow(dead_code)] struct SysWithLifetime<'a>(&'a u8); +#[allow(dead_code)] struct SysLocal(*const u8); impl_sys!(SysA SysB SysC SysD SysLocal); -impl<'a, 'b> System<'a> for SysWithLifetime<'b> { +impl<'a> System<'a> for SysWithLifetime<'_> { type SystemData = Read<'a, u64>; fn run(&mut self, nr: Read<'a, u64>) { diff --git a/examples/thread_local.rs b/examples/thread_local.rs index 51b231b..3200289 100644 --- a/examples/thread_local.rs +++ b/examples/thread_local.rs @@ -1,4 +1,6 @@ -use shred::{DispatcherBuilder, Read, ResourceId, System, SystemData, World, Write}; +#[cfg(not(feature = "shred-derive"))] +use shred::ResourceId; +use shred::{DispatcherBuilder, Read, System, SystemData, World, Write}; #[derive(Debug, Default)] struct ResA; @@ -13,6 +15,7 @@ struct Data<'a> { b: Write<'a, ResB>, } +#[allow(dead_code)] struct EmptySystem(*mut i8); // System is not thread-safe impl<'a> System<'a> for EmptySystem { diff --git a/src/dispatch/async_dispatcher.rs b/src/dispatch/async_dispatcher.rs index 8281770..25bbf7e 100644 --- a/src/dispatch/async_dispatcher.rs +++ b/src/dispatch/async_dispatcher.rs @@ -1,6 +1,6 @@ use std::{ borrow::Borrow, - sync::{mpsc, Arc, RwLock}, + sync::{Arc, RwLock, mpsc}, }; use crate::{ @@ -32,7 +32,7 @@ pub struct AsyncDispatcher<'a, R> { thread_pool: Arc>, } -impl<'a, R> AsyncDispatcher<'a, R> +impl AsyncDispatcher<'_, R> where R: Borrow + Send + Sync + 'static, { diff --git a/src/dispatch/builder.rs b/src/dispatch/builder.rs index 2dc4344..349a39c 100644 --- a/src/dispatch/builder.rs +++ b/src/dispatch/builder.rs @@ -6,10 +6,10 @@ use ahash::AHashMap as HashMap; use crate::dispatch::dispatcher::ThreadPoolWrapper; use crate::{ dispatch::{ + BatchAccessor, BatchController, Dispatcher, batch::BatchControllerSystem, dispatcher::{SystemId, ThreadLocal}, stage::StagesBuilder, - BatchAccessor, BatchController, Dispatcher, }, system::{RunNow, System, SystemData}, }; @@ -448,7 +448,7 @@ impl<'b> DispatcherBuilder<'static, 'b> { } } -impl<'a, 'b> fmt::Debug for DispatcherBuilder<'a, 'b> { +impl fmt::Debug for DispatcherBuilder<'_, '_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.stages_builder.write_par_seq(f, &self.map) } diff --git a/src/dispatch/dispatcher.rs b/src/dispatch/dispatcher.rs index e6f064c..e71ad7f 100644 --- a/src/dispatch/dispatcher.rs +++ b/src/dispatch/dispatcher.rs @@ -1,7 +1,7 @@ use smallvec::SmallVec; use crate::{ - dispatch::{stage::Stage, SendDispatcher}, + dispatch::{SendDispatcher, stage::Stage}, system::RunNow, world::World, }; @@ -18,7 +18,7 @@ pub struct Dispatcher<'a, 'b> { thread_local: ThreadLocal<'b>, } -impl<'a, 'b> Dispatcher<'a, 'b> { +impl<'a> Dispatcher<'a, '_> { /// Sets up all the systems which means they are gonna add default values /// for the resources they need. pub fn setup(&mut self, world: &mut World) { @@ -119,7 +119,7 @@ impl<'a, 'b> Dispatcher<'a, 'b> { } } -impl<'a, 'b, 'c> RunNow<'a> for Dispatcher<'b, 'c> { +impl RunNow<'_> for Dispatcher<'_, '_> { fn run_now(&mut self, world: &World) { self.dispatch(world); } @@ -194,7 +194,7 @@ mod tests { struct Panic; - impl<'a> System<'a> for Panic { + impl System<'_> for Panic { type SystemData = (); fn run(&mut self, _: Self::SystemData) { diff --git a/src/dispatch/par_seq.rs b/src/dispatch/par_seq.rs index 4e15bea..913c52d 100644 --- a/src/dispatch/par_seq.rs +++ b/src/dispatch/par_seq.rs @@ -1,6 +1,6 @@ use std::borrow::Borrow; -use rayon::{join, ThreadPool}; +use rayon::{ThreadPool, join}; use crate::{ dispatch::util::check_intersection, @@ -68,7 +68,7 @@ macro_rules! seq { }; } -impl<'a> System<'a> for Nil { +impl System<'_> for Nil { type SystemData = (); fn run(&mut self, _: Self::SystemData) {} @@ -235,7 +235,7 @@ where } } -impl<'a, P, T> RunNow<'a> for ParSeq +impl RunNow<'_> for ParSeq where P: Borrow, T: for<'b> RunWithPool<'b>, @@ -391,7 +391,7 @@ where #[cfg(test)] mod tests { use super::*; - use std::sync::{atomic::*, Arc}; + use std::sync::{Arc, atomic::*}; fn new_tp() -> ThreadPool { use rayon::ThreadPoolBuilder; @@ -412,7 +412,7 @@ mod tests { struct A(Arc); - impl<'a> System<'a> for A { + impl System<'_> for A { type SystemData = (); fn run(&mut self, _: Self::SystemData) { @@ -440,7 +440,7 @@ mod tests { struct A(Arc); - impl<'a> System<'a> for A { + impl System<'_> for A { type SystemData = (); fn run(&mut self, _: Self::SystemData) { diff --git a/src/dispatch/send_dispatcher.rs b/src/dispatch/send_dispatcher.rs index 6edcb9b..77471fb 100644 --- a/src/dispatch/send_dispatcher.rs +++ b/src/dispatch/send_dispatcher.rs @@ -13,7 +13,7 @@ pub struct SendDispatcher<'a> { pub(super) thread_pool: ::std::sync::Arc<::std::sync::RwLock>, } -impl<'a> SendDispatcher<'a> { +impl SendDispatcher<'_> { /// Sets up all the systems which means they are gonna add default values /// for the resources they need. pub fn setup(&mut self, world: &mut World) { @@ -104,7 +104,7 @@ impl<'a> SendDispatcher<'a> { } } -impl<'a, 'b> RunNow<'a> for SendDispatcher<'b> { +impl RunNow<'_> for SendDispatcher<'_> { fn run_now(&mut self, world: &World) { self.dispatch(world); } diff --git a/src/dispatch/stage.rs b/src/dispatch/stage.rs index cf4796e..06a506b 100644 --- a/src/dispatch/stage.rs +++ b/src/dispatch/stage.rs @@ -2,11 +2,11 @@ //! words: //! //! 1) A *stage* is a part of the dispatching which contains work that can be -//! done in parallel +//! done in parallel //! //! 2) In each stage, there's a *group*. A group is a list of systems, which are -//! executed in order. Thus, systems of a group may conflict with each other, -//! but groups of a stage may not. +//! executed in order. Thus, systems of a group may conflict with each other, +//! but groups of a stage may not. //! //! So the actual dispatching works like this (pseudo code): //! @@ -29,9 +29,9 @@ //! say: //! //! > If a system only conflicts with one group of a stage, it gets executed -//! after all the other systems of this group, but only if by doing this, the -//! running times of the groups of this stage get closer to each other (called -//! balanced in code). +//! > after all the other systems of this group, but only if by doing this, the +//! > running times of the groups of this stage get closer to each other (called +//! > balanced in code). use std::fmt; @@ -81,7 +81,7 @@ pub struct Stage<'a> { groups: GroupVec, MAX_SYSTEMS_PER_GROUP>>, } -impl<'a> Stage<'a> { +impl Stage<'_> { fn new() -> Self { Default::default() } @@ -236,7 +236,7 @@ impl<'a> StagesBuilder<'a> { let system: &SystemId = system; let mut name = (*map.get(system).unwrap()).to_string(); - name = name.replace(|c| c == ' ' || c == '-' || c == '/', "_"); + name = name.replace([' ', '-', '/'], "_"); writeln!(f, "\t\t\t{},", name)?; } @@ -558,7 +558,7 @@ mod tests { struct Sys; - impl<'a> System<'a> for Sys { + impl System<'_> for Sys { type SystemData = (); fn run(&mut self, _: Self::SystemData) {} diff --git a/src/lib.rs b/src/lib.rs index 1c0c96b..becd407 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,8 +82,7 @@ //! `ParSeq`. Using it is bit trickier, but it allows dispatching without any //! virtual function calls. -#![deny(unused_must_use, clippy::disallowed_types)] -#![deny(unsafe_op_in_unsafe_fn)] +#![deny(unused_must_use, clippy::disallowed_types, unsafe_op_in_unsafe_fn)] #![warn(missing_docs)] /// Re-exports from [`atomic_refcell`] diff --git a/src/system.rs b/src/system.rs index dca8c78..b9f27fb 100644 --- a/src/system.rs +++ b/src/system.rs @@ -371,7 +371,7 @@ pub trait DynamicSystemData<'a> { fn fetch(access: &Self::Accessor, world: &'a World) -> Self; } -impl<'a, T: ?Sized> SystemData<'a> for PhantomData { +impl SystemData<'_> for PhantomData { fn setup(_: &mut World) {} fn fetch(_: &World) -> Self { @@ -379,11 +379,11 @@ impl<'a, T: ?Sized> SystemData<'a> for PhantomData { } fn reads() -> Vec { - vec![] + Vec::new() } fn writes() -> Vec { - vec![] + Vec::new() } } diff --git a/src/world/data.rs b/src/world/data.rs index 061707a..1db442d 100644 --- a/src/world/data.rs +++ b/src/world/data.rs @@ -21,7 +21,7 @@ pub struct Read<'a, T: 'a, F = DefaultProvider> { phantom: PhantomData, } -impl<'a, T, F> Deref for Read<'a, T, F> +impl Deref for Read<'_, T, F> where T: Resource, { @@ -76,7 +76,7 @@ pub struct Write<'a, T: 'a, F = DefaultProvider> { phantom: PhantomData, } -impl<'a, T, F> Deref for Write<'a, T, F> +impl Deref for Write<'_, T, F> where T: Resource, { @@ -87,7 +87,7 @@ where } } -impl<'a, T, F> DerefMut for Write<'a, T, F> +impl DerefMut for Write<'_, T, F> where T: Resource, { diff --git a/src/world/mod.rs b/src/world/mod.rs index 3a4d688..e78e7a9 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -14,8 +14,8 @@ use std::{ use ahash::AHashMap as HashMap; -use crate::cell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use crate::SystemData; +use crate::cell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use self::entry::create_entry; @@ -37,7 +37,7 @@ pub struct Fetch<'a, T: 'a> { phantom: PhantomData<&'a T>, } -impl<'a, T> Deref for Fetch<'a, T> +impl Deref for Fetch<'_, T> where T: Resource, { @@ -48,7 +48,7 @@ where } } -impl<'a, T> Clone for Fetch<'a, T> { +impl Clone for Fetch<'_, T> { fn clone(&self) -> Self { Fetch { inner: AtomicRef::clone(&self.inner), @@ -70,7 +70,7 @@ pub struct FetchMut<'a, T: 'a> { phantom: PhantomData<&'a mut T>, } -impl<'a, T> Deref for FetchMut<'a, T> +impl Deref for FetchMut<'_, T> where T: Resource, { @@ -81,7 +81,7 @@ where } } -impl<'a, T> DerefMut for FetchMut<'a, T> +impl DerefMut for FetchMut<'_, T> where T: Resource, { @@ -181,10 +181,10 @@ impl ResourceId { /// aware of: /// /// 1. There are many utility methods Specs provides. To use them, you need to -/// import `specs::WorldExt`. +/// import `specs::WorldExt`. /// 2. You should not use [World::empty], but rather `specs::WorldExt::new`. The -/// latter can simply be called using `World::new()`, as long as `WorldExt` -/// is imported. +/// latter can simply be called using `World::new()`, as long as `WorldExt` +/// is imported. /// /// # Resource Ids /// diff --git a/tests/dispatch.rs b/tests/dispatch.rs index 02741b7..1bdc07d 100644 --- a/tests/dispatch.rs +++ b/tests/dispatch.rs @@ -99,7 +99,7 @@ impl<'a> System<'a> for DummySysMut { struct Whatever<'a>(&'a i32); -impl<'a, 'b> System<'a> for Whatever<'b> { +impl System<'_> for Whatever<'_> { type SystemData = (); fn run(&mut self, _: Self::SystemData) {