Skip to content

Commit

Permalink
Fix new Fn<Arguments: Tuple> bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Hpmason committed Nov 14, 2022
1 parent 9282992 commit 9c6d5a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/detours/statik.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::error::{Error, Result};
use crate::{Function, GenericDetour};
use std::marker::Tuple;
use std::sync::atomic::{AtomicPtr, Ordering};
use std::{mem, ptr};

Expand Down Expand Up @@ -104,6 +105,7 @@ impl<T: Function> StaticDetour<T> {
pub unsafe fn initialize<D>(&self, target: T, closure: D) -> Result<&Self>
where
D: Fn<T::Arguments, Output = T::Output> + Send + 'static,
<T as Function>::Arguments: Tuple,
{
let mut detour = Box::new(GenericDetour::new(target, self.ffi)?);
if self
Expand Down Expand Up @@ -155,6 +157,7 @@ impl<T: Function> StaticDetour<T> {
pub fn set_detour<C>(&self, closure: C)
where
C: Fn<T::Arguments, Output = T::Output> + Send + 'static,
<T as Function>::Arguments: Tuple,
{
let previous = self
.closure
Expand All @@ -175,7 +178,10 @@ impl<T: Function> StaticDetour<T> {

/// Returns a transient reference to the active detour.
#[doc(hidden)]
pub fn __detour(&self) -> &dyn Fn<T::Arguments, Output = T::Output> {
pub fn __detour(&self) -> &dyn Fn<T::Arguments, Output = T::Output>
where
<T as Function>::Arguments: Tuple,
{
// TODO: This is not 100% thread-safe in case the thread is stopped
unsafe { self.closure.load(Ordering::SeqCst).as_ref() }
.ok_or(Error::NotInitialized)
Expand Down
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#![recursion_limit = "1024"]
#![cfg_attr(feature = "nightly", feature(unboxed_closures, abi_thiscall))]
#![cfg_attr(
feature = "nightly",
<<<<<<< HEAD
feature(unboxed_closures, abi_thiscall, tuple_trait)
=======
feature(const_fn, const_fn_trait_bound, unboxed_closures, abi_thiscall)
>>>>>>> parent of 3b6f17a (Remove obsolete const_fn feature gate on nightly)
)]
#![cfg_attr(
all(feature = "nightly", test),
feature(naked_functions, core_intrinsics)
Expand Down

0 comments on commit 9c6d5a2

Please sign in to comment.