Skip to content

Commit 9c6d5a2

Browse files
committed
Fix new Fn<Arguments: Tuple> bounds
See: rust-lang/rust#99943
1 parent 9282992 commit 9c6d5a2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/detours/statik.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::error::{Error, Result};
22
use crate::{Function, GenericDetour};
3+
use std::marker::Tuple;
34
use std::sync::atomic::{AtomicPtr, Ordering};
45
use std::{mem, ptr};
56

@@ -104,6 +105,7 @@ impl<T: Function> StaticDetour<T> {
104105
pub unsafe fn initialize<D>(&self, target: T, closure: D) -> Result<&Self>
105106
where
106107
D: Fn<T::Arguments, Output = T::Output> + Send + 'static,
108+
<T as Function>::Arguments: Tuple,
107109
{
108110
let mut detour = Box::new(GenericDetour::new(target, self.ffi)?);
109111
if self
@@ -155,6 +157,7 @@ impl<T: Function> StaticDetour<T> {
155157
pub fn set_detour<C>(&self, closure: C)
156158
where
157159
C: Fn<T::Arguments, Output = T::Output> + Send + 'static,
160+
<T as Function>::Arguments: Tuple,
158161
{
159162
let previous = self
160163
.closure
@@ -175,7 +178,10 @@ impl<T: Function> StaticDetour<T> {
175178

176179
/// Returns a transient reference to the active detour.
177180
#[doc(hidden)]
178-
pub fn __detour(&self) -> &dyn Fn<T::Arguments, Output = T::Output> {
181+
pub fn __detour(&self) -> &dyn Fn<T::Arguments, Output = T::Output>
182+
where
183+
<T as Function>::Arguments: Tuple,
184+
{
179185
// TODO: This is not 100% thread-safe in case the thread is stopped
180186
unsafe { self.closure.load(Ordering::SeqCst).as_ref() }
181187
.ok_or(Error::NotInitialized)

src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#![recursion_limit = "1024"]
2-
#![cfg_attr(feature = "nightly", feature(unboxed_closures, abi_thiscall))]
2+
#![cfg_attr(
3+
feature = "nightly",
4+
<<<<<<< HEAD
5+
feature(unboxed_closures, abi_thiscall, tuple_trait)
6+
=======
7+
feature(const_fn, const_fn_trait_bound, unboxed_closures, abi_thiscall)
8+
>>>>>>> parent of 3b6f17a (Remove obsolete const_fn feature gate on nightly)
9+
)]
310
#![cfg_attr(
411
all(feature = "nightly", test),
512
feature(naked_functions, core_intrinsics)

0 commit comments

Comments
 (0)