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 CI errors #240

Merged
merged 3 commits into from
Feb 22, 2025
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
35 changes: 18 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
Expand Down
1 change: 1 addition & 0 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions examples/batch_dispatching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -71,7 +72,6 @@ impl<'a> System<'a> for SayHelloSystem {
}

/// System that says "Buy Potato"

pub struct BuyPotatoSystem;

impl<'a> System<'a> for BuyPotatoSystem {
Expand All @@ -83,7 +83,6 @@ impl<'a> System<'a> for BuyPotatoSystem {
}

/// System that says "Buy Tomato"

pub struct BuyTomatoSystem;

impl<'a> System<'a> for BuyTomatoSystem {
Expand Down
7 changes: 4 additions & 3 deletions examples/dyn_sys_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
//! language.
//!
//! It does that by implementing `DynamicSystemData` and using `MetaTable`.
#![allow(clippy::disallowed_names)]

extern crate shred;

// faster alternative to std's HashMap
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 {
Expand Down Expand Up @@ -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::<ResourceTable>();
Expand Down
5 changes: 2 additions & 3 deletions examples/multi_batch_dispatching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -71,7 +72,6 @@ impl<'a> System<'a> for SayHelloSystem {
}

/// System that says "Buy Potato"

pub struct BuyPotatoSystem;

impl<'a> System<'a> for BuyPotatoSystem {
Expand All @@ -83,7 +83,6 @@ impl<'a> System<'a> for BuyPotatoSystem {
}

/// System that says "Buy Tomato"

pub struct BuyTomatoSystem;

impl<'a> System<'a> for BuyTomatoSystem {
Expand Down
4 changes: 3 additions & 1 deletion examples/par_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>) {
Expand Down
5 changes: 4 additions & 1 deletion examples/thread_local.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/async_dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
borrow::Borrow,
sync::{mpsc, Arc, RwLock},
sync::{Arc, RwLock, mpsc},
};

use crate::{
Expand Down Expand Up @@ -32,7 +32,7 @@ pub struct AsyncDispatcher<'a, R> {
thread_pool: Arc<RwLock<ThreadPoolWrapper>>,
}

impl<'a, R> AsyncDispatcher<'a, R>
impl<R> AsyncDispatcher<'_, R>
where
R: Borrow<World> + Send + Sync + 'static,
{
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
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},
};
Expand Down Expand Up @@ -257,7 +257,7 @@
pub fn add_batch<T>(
&mut self,
controller: T,
mut dispatcher_builder: DispatcherBuilder<'a, 'b>,

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (nightly)

variable does not need to be mutable

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (nightly)

variable does not need to be mutable

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (beta)

variable does not need to be mutable

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (beta)

variable does not need to be mutable

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (stable)

variable does not need to be mutable

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (stable)

variable does not need to be mutable

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (1.65.0)

variable does not need to be mutable

Check warning on line 260 in src/dispatch/builder.rs

View workflow job for this annotation

GitHub Actions / Build and Test (Linux) (1.65.0)

variable does not need to be mutable
name: &str,
dep: &[&str],
) where
Expand Down Expand Up @@ -448,7 +448,7 @@
}
}

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)
}
Expand Down
8 changes: 4 additions & 4 deletions src/dispatch/dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use smallvec::SmallVec;

use crate::{
dispatch::{stage::Stage, SendDispatcher},
dispatch::{SendDispatcher, stage::Stage},
system::RunNow,
world::World,
};
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions src/dispatch/par_seq.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Borrow;

use rayon::{join, ThreadPool};
use rayon::{ThreadPool, join};

use crate::{
dispatch::util::check_intersection,
Expand Down Expand Up @@ -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) {}
Expand Down Expand Up @@ -235,7 +235,7 @@ where
}
}

impl<'a, P, T> RunNow<'a> for ParSeq<P, T>
impl<P, T> RunNow<'_> for ParSeq<P, T>
where
P: Borrow<ThreadPool>,
T: for<'b> RunWithPool<'b>,
Expand Down Expand Up @@ -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;
Expand All @@ -412,7 +412,7 @@ mod tests {

struct A(Arc<AtomicUsize>);

impl<'a> System<'a> for A {
impl System<'_> for A {
type SystemData = ();

fn run(&mut self, _: Self::SystemData) {
Expand Down Expand Up @@ -440,7 +440,7 @@ mod tests {

struct A(Arc<AtomicUsize>);

impl<'a> System<'a> for A {
impl System<'_> for A {
type SystemData = ();

fn run(&mut self, _: Self::SystemData) {
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/send_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct SendDispatcher<'a> {
pub(super) thread_pool: ::std::sync::Arc<::std::sync::RwLock<ThreadPoolWrapper>>,
}

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) {
Expand Down Expand Up @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions src/dispatch/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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):
//!
Expand All @@ -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;

Expand Down Expand Up @@ -81,7 +81,7 @@ pub struct Stage<'a> {
groups: GroupVec<ArrayVec<SystemExecSend<'a>, MAX_SYSTEMS_PER_GROUP>>,
}

impl<'a> Stage<'a> {
impl Stage<'_> {
fn new() -> Self {
Default::default()
}
Expand Down Expand Up @@ -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)?;
}
Expand Down Expand Up @@ -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) {}
Expand Down
Loading
Loading