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 all warnings for Rust 1.84.0 #51

Merged
merged 2 commits into from
Jan 23, 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
38 changes: 18 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@
//!
//! Crate-level features include:
//! - `parallel-runtime`: use Rayon to execute reactions in parallel
//! when possible. This is not yet the default. For some applications,
//! where there is no data parallelism, this may harm performance
//! (as well as pull in unneeded dependencies) and should be off.
//! when possible. This is not yet the default. For some applications,
//! where there is no data parallelism, this may harm performance
//! (as well as pull in unneeded dependencies) and should be off.
//! - `wide-ids`: Enables 64-bit wide reaction ids on 64-bit
//! architectures. This may reduce performance, but allows for
//! 2^32 reactor instances compared to the default of 2^16,
//! which may feel a bit tight for some applications. On machines
//! with a pointer-width of less than 64 bits, ID types are
//! always 32 bits. The feature also widens trigger ids to 64 bits
//! if possible, which enables 2^64 individual trigger components
//! (ports, actions, etc.) instead of 2^32.
//! architectures. This may reduce performance, but allows for
//! 2^32 reactor instances compared to the default of 2^16,
//! which may feel a bit tight for some applications. On machines
//! with a pointer-width of less than 64 bits, ID types are
//! always 32 bits. The feature also widens trigger ids to 64 bits
//! if possible, which enables 2^64 individual trigger components
//! (ports, actions, etc.) instead of 2^32.
//! - `vec-id-sets`: Change the implementation of reaction sets
//! to be a sorted vector instead of a hash set. This has a positive
//! performance impact, as reaction sets are typically very small.
//! More testing is required to determine pathological cases.
//! This is a default feature.
//! to be a sorted vector instead of a hash set. This has a positive
//! performance impact, as reaction sets are typically very small.
//! More testing is required to determine pathological cases.
//! This is a default feature.
//! - `no-unsafe`: disable optimisations that use unsafe code in this runtime.
//! Just provided for comparison, should probably be removed (unsafe code is fine).
//! Just provided for comparison, should probably be removed (unsafe code is fine).

// #![deny(unused_crate_dependencies)]
#![deny(unused_extern_crates)]
Expand All @@ -61,18 +61,16 @@
#[macro_use]
extern crate array_macro;
#[cfg(test)]
#[allow(unused)]
#[allow(unused, unused_imports)]
#[macro_use]
extern crate assert_matches;
#[macro_use]
extern crate index_vec;
// #[macro_use]
// extern crate index_vec;
#[macro_use]
extern crate log;
#[cfg(feature = "parallel-runtime")]
extern crate rayon;
#[macro_use]
extern crate smallvec;
#[macro_use]
extern crate static_assertions;
#[macro_use]
extern crate cfg_if;
Expand Down
2 changes: 1 addition & 1 deletion src/ports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ struct PortCell<T: Sync> {
/// - say you have bound A -> B, then B -> C
/// - so all three refer to the equiv class of A, whose downstream is now {B, C}
/// - if you then try binding C -> A, then we can know
/// that C is in the downstream of A, indicating that there is a cycle.
/// that C is in the downstream of A, indicating that there is a cycle.
downstreams: Downstreams<T>,
}

Expand Down
7 changes: 4 additions & 3 deletions src/scheduler/assembly_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ where
}

/// Final result of the assembly of a reactor.
pub struct FinishedReactor<'x, S>(AssemblyCtx<'x, S>, S)
#[allow(unused_variables)]
pub struct FinishedReactor<'x, S>(PhantomData<&'x mut u8>, S)
where
S: ReactorInitializer;

Expand Down Expand Up @@ -148,8 +149,8 @@ where
self,
build_reactor_tree: impl FnOnce(Self) -> AssemblyResult<AssemblyIntermediate<'x, S>>,
) -> AssemblyResult<FinishedReactor<'x, S>> {
let AssemblyIntermediate(ich, reactor) = build_reactor_tree(self)?;
Ok(FinishedReactor(ich, reactor))
let AssemblyIntermediate(_, reactor) = build_reactor_tree(self)?;
Ok(FinishedReactor(PhantomData, reactor))
}

/// Innermost function.
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::*;
/// allows mutating the event queue of the scheduler.
/// Only the interactions declared at assembly time
/// are allowed.

///
// Implementation details:
// ReactionCtx is an API built around a ReactionWave. A single
// ReactionCtx may be used for multiple ReactionWaves, but
Expand Down
6 changes: 3 additions & 3 deletions src/scheduler/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub(super) struct DepGraph {
/// - port/action -> reaction: the port/action triggers the reaction
/// - port -> port: a binding of a port to another
/// - reaction n -> reaction m: means n has higher priority
/// than m, only filled in for reactions of the same reactor.
/// than m, only filled in for reactions of the same reactor.
dataflow: DepGraphImpl,

/// Maps global IDs back to graph indices.
Expand Down Expand Up @@ -342,7 +342,7 @@ enum EdgeWeight {
/// if they're labeled `Default`, they're trigger dependencies,
/// otherwise use dependencies.
Default,
///
/// See [Default].
Use,
}

Expand Down Expand Up @@ -604,7 +604,7 @@ impl<'x> ExecutableReactions<'x> {
}

#[inline]
pub fn next_batch<'a>(&'a self, min_level_exclusive: KeyRef<&LevelIx>) -> Option<(KeyRef<&'a LevelIx>, &Level)> {
pub fn next_batch<'a>(&'a self, min_level_exclusive: KeyRef<&LevelIx>) -> Option<(KeyRef<&'a LevelIx>, &'a Level)> {
self.levels
.next_mapping(min_level_exclusive)
.map(|(ix, cow)| (ix, cow.as_ref()))
Expand Down
1 change: 1 addition & 0 deletions src/scheduler/scheduler_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ impl<'x> SyncScheduler<'x> {
/// internals are not copied).
/// So long as the framework entirely controls the lifetime
/// of SyncScheduler instances, this is enforceable.
#[allow(non_local_definitions)]
unsafe impl Send for SyncScheduler<'_> {}

// install makes calls to parallel iterators use that thread pool
Expand Down
76 changes: 38 additions & 38 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,6 @@ pub(crate) fn do_write<X>(
write!(f, "{}", suffix)
}

/// Shorthand for using [After](crate::Offset::After) together with [delay].
///
/// ```
/// use std::time::Duration;
/// use reactor_rt::{after, Offset::After};
///
/// assert_eq!(after!(10 ns), After(Duration::from_nanos(10)));
/// assert_eq!(after!(2 min), After(Duration::from_secs(120)));
/// ```
#[macro_export]
macro_rules! after {
($amount:tt $unit:tt) => { $crate::Offset::After($crate::delay!($amount $unit)) }
}

/// Creates a [Duration] value using the same syntax as in LF.
///
/// ```
Expand Down Expand Up @@ -133,6 +119,44 @@ macro_rules! delay {
($amount:tt $i:ident) => { compile_error!(concat!("Unknown time unit `", stringify!($i), "`")) };
}

/// Shorthand for using [After](crate::Offset::After) together with [delay].
///
/// ```
/// use std::time::Duration;
/// use reactor_rt::{after, Offset::After};
///
/// assert_eq!(after!(10 ns), After(Duration::from_nanos(10)));
/// assert_eq!(after!(2 min), After(Duration::from_secs(120)));
/// ```
#[macro_export]
macro_rules! after {
($amount:tt $unit:tt) => { $crate::Offset::After($crate::delay!($amount $unit)) }
}

/// Convenient macro to [create a tag](crate::EventTag).
/// This is just a shorthand for using the constructor together
/// with the syntax of [delay].
///
/// ```no_run
/// use reactor_rt::{tag, delay};
///
/// tag!(T0 + 20 ms);
/// tag!(T0 + 60 ms);
/// tag!(T0); // the origin tag
/// // with a microstep:
/// tag!(T0, 1);
/// tag!(T0 + 3 sec, 1);
/// ```
#[macro_export]
macro_rules! tag {
(T0) => {$crate::EventTag::ORIGIN};
(T0, $microstep:expr) => {tag!(T0 + 0 sec, $microstep)};
(T0 + $amount:tt $unit:ident) => {tag!(T0 + $amount $unit, 0)};
(T0 + $amount:tt $unit:ident, $microstep:expr) => {
$crate::EventTag::offset($crate::delay!($amount $unit), $microstep)
};
}

/// Convenient macro to assert equality of the current tag.
/// This is just shorthand for using `assert_eq!` with the
/// syntax of [tag].
Expand Down Expand Up @@ -164,30 +188,6 @@ macro_rules! assert_tag_is {
};
}

/// Convenient macro to [create a tag](crate::EventTag).
/// This is just a shorthand for using the constructor together
/// with the syntax of [delay].
///
/// ```no_run
/// use reactor_rt::{tag, delay};
///
/// tag!(T0 + 20 ms);
/// tag!(T0 + 60 ms);
/// tag!(T0); // the origin tag
/// // with a microstep:
/// tag!(T0, 1);
/// tag!(T0 + 3 sec, 1);
/// ```
#[macro_export]
macro_rules! tag {
(T0) => {$crate::EventTag::ORIGIN};
(T0, $microstep:expr) => {tag!(T0 + 0 sec, $microstep)};
(T0 + $amount:tt $unit:ident) => {tag!(T0 + $amount $unit, 0)};
(T0 + $amount:tt $unit:ident, $microstep:expr) => {
$crate::EventTag::offset($crate::delay!($amount $unit), $microstep)
};
}

/// A unit of time, used in LF.
#[derive(Debug)]
pub enum TimeUnit {
Expand Down
Loading