Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit f6bc895

Browse files
authored
Merge pull request #205 from alexcrichton/remove-for-a
Reduce usage of `for<'a>` in trait bounds
2 parents 40aceb3 + 84b53a9 commit f6bc895

2 files changed

Lines changed: 17 additions & 24 deletions

File tree

crates/wasmtime/src/runtime/component/concurrent.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ impl Instance {
13041304
) -> Result<V>
13051305
where
13061306
U: 'static,
1307-
F: for<'a> FnOnce(&'a mut Accessor<U>) -> Pin<Box<dyn Future<Output = V> + Send + 'a>>
1307+
F: FnOnce(&mut Accessor<U>) -> Pin<Box<dyn Future<Output = V> + Send + '_>>
13081308
+ Send
13091309
+ 'static,
13101310
{
@@ -1320,7 +1320,7 @@ impl Instance {
13201320
) -> Pin<Box<dyn Future<Output = V> + Send + 'static>>
13211321
where
13221322
U: 'static,
1323-
F: for<'a> FnOnce(&'a mut Accessor<U>) -> Pin<Box<dyn Future<Output = V> + Send + 'a>>
1323+
F: FnOnce(&mut Accessor<U>) -> Pin<Box<dyn Future<Output = V> + Send + '_>>
13241324
+ Send
13251325
+ 'static,
13261326
{
@@ -2461,10 +2461,7 @@ impl Instance {
24612461
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'static>>
24622462
where
24632463
T: 'static,
2464-
F: for<'a> Fn(
2465-
&'a mut Accessor<T>,
2466-
P,
2467-
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'a>>
2464+
F: Fn(&mut Accessor<T>, P) -> Pin<Box<dyn Future<Output = Result<R>> + Send + '_>>
24682465
+ Send
24692466
+ Sync
24702467
+ 'static,

crates/wasmtime/src/runtime/component/func/host.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ impl core::fmt::Debug for HostFunc {
3939
impl HostFunc {
4040
fn from_canonical<T: 'static, F, P, R>(func: F) -> Arc<HostFunc>
4141
where
42-
F: for<'a> Fn(
43-
StoreContextMut<'a, T>,
42+
F: Fn(
43+
StoreContextMut<'_, T>,
4444
Instance,
4545
P,
4646
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'static>>
@@ -75,10 +75,7 @@ impl HostFunc {
7575
pub(crate) fn from_concurrent<T: 'static, F, P, R>(func: F) -> Arc<HostFunc>
7676
where
7777
T: 'static,
78-
F: for<'a> Fn(
79-
&'a mut Accessor<T>,
80-
P,
81-
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'a>>
78+
F: Fn(&mut Accessor<T>, P) -> Pin<Box<dyn Future<Output = Result<R>> + Send + '_>>
8279
+ Send
8380
+ Sync
8481
+ 'static,
@@ -105,8 +102,8 @@ impl HostFunc {
105102
storage_len: usize,
106103
) -> bool
107104
where
108-
F: for<'a> Fn(
109-
StoreContextMut<'a, T>,
105+
F: Fn(
106+
StoreContextMut<'_, T>,
110107
Instance,
111108
P,
112109
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'static>>
@@ -139,13 +136,12 @@ impl HostFunc {
139136

140137
fn new_dynamic_canonical<T: 'static, F>(func: F) -> Arc<HostFunc>
141138
where
142-
F: for<'a> Fn(
143-
StoreContextMut<'a, T>,
139+
F: Fn(
140+
StoreContextMut<'_, T>,
144141
Instance,
145142
Vec<Val>,
146143
usize,
147-
)
148-
-> Pin<Box<dyn Future<Output = Result<Vec<Val>>> + Send + 'static>>
144+
) -> Pin<Box<dyn Future<Output = Result<Vec<Val>>> + Send + 'static>>
149145
+ Send
150146
+ Sync
151147
+ 'static,
@@ -253,8 +249,8 @@ unsafe fn call_host<T, Params, Return, F>(
253249
closure: F,
254250
) -> Result<()>
255251
where
256-
F: for<'a> Fn(
257-
StoreContextMut<'a, T>,
252+
F: Fn(
253+
StoreContextMut<'_, T>,
258254
Instance,
259255
Params,
260256
) -> Pin<Box<dyn Future<Output = Result<Return>> + Send + 'static>>
@@ -709,8 +705,8 @@ unsafe fn call_host_dynamic<T, F>(
709705
closure: F,
710706
) -> Result<()>
711707
where
712-
F: for<'a> Fn(
713-
StoreContextMut<'a, T>,
708+
F: Fn(
709+
StoreContextMut<'_, T>,
714710
Instance,
715711
Vec<Val>,
716712
usize,
@@ -937,8 +933,8 @@ extern "C" fn dynamic_entrypoint<T: 'static, F>(
937933
storage_len: usize,
938934
) -> bool
939935
where
940-
F: for<'a> Fn(
941-
StoreContextMut<'a, T>,
936+
F: Fn(
937+
StoreContextMut<'_, T>,
942938
Instance,
943939
Vec<Val>,
944940
usize,

0 commit comments

Comments
 (0)