Skip to content
Open
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
10 changes: 10 additions & 0 deletions library/core/src/ops/async_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ mod impls {
F::async_call_mut(self, args)
}
}

#[stable(feature = "async_closure", since = "1.85.0")]
impl<'a, A: Tuple, F: ?Sized> AsyncFn<A> for &'a mut F
where
F: AsyncFn<A>,
{
extern "rust-call" fn async_call(&self, args: A) -> Self::CallRefFuture<'_> {
F::async_call(*self, args)
}
}
}

mod internal_implementation_detail {
Expand Down
11 changes: 11 additions & 0 deletions library/core/src/ops/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,15 @@ mod impls {
(*self).call_mut(args)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this "since" line correct?

Copy link
Member Author

@Kivooeo Kivooeo Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be insta stable so I think so and it should be available on all versions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "should be available on all versions"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you mean that if I make it since = 1.91 it will work not only in 1.91+? because in my opinion this should be available in all versions since 1.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute is only describing when it was added for docs. We cannot add things to old versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, ok then, I will change it after crater

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, seems like I can't?

error[E0711]: feature `async_closure` is declared stable since 1.93.0, but was previously declared stable since 1.85.0
   --> library/core/src/ops/async_function.rs:130:5
    |
130 |     #[stable(feature = "async_closure", since = "1.93.0")]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0711]: feature `rust1` is declared stable since 1.93.0, but was previously declared stable since 1.0.0
   --> library/core/src/ops/function.rs:314:5
    |
314 |     #[stable(feature = "rust1", since = "1.93.0")]
    |    

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it don't feel correct to change stable since for all impls

#[rustc_const_unstable(feature = "const_trait_impl", issue = "143874")]
impl<A: Tuple, F: ?Sized> const Fn<A> for &mut F
where
F: [const] Fn<A>,
{
extern "rust-call" fn call(&self, args: A) -> F::Output {
(**self).call(args)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ LL | Wrapper::<function>::call;
= note: the following trait bounds were not satisfied:
`Wrapper<function>: Fn<_>`
which is required by `&Wrapper<function>: Fn<_>`
`Wrapper<function>: Fn<_>`
which is required by `&mut Wrapper<function>: Fn<_>`
note: the trait `Fn` must be implemented
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= help: items from traits can only be used if the trait is implemented and in scope
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/impl-trait/where-allowed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { pani
= note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`:
- impl<A, F> Fn<A> for &F
where A: Tuple, F: Fn<A>, F: ?Sized;
- impl<A, F> Fn<A> for &mut F
where A: Tuple, F: Fn<A>, F: ?Sized;
- impl<Args, F, A> Fn<Args> for Box<F, A>
where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized;
- impl<F, Args> Fn<Args> for Exclusive<F>
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/traits/next-solver/well-formed-in-relate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LL | x = unconstrained_map();
= note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`:
- impl<A, F> Fn<A> for &F
where A: Tuple, F: Fn<A>, F: ?Sized;
- impl<A, F> Fn<A> for &mut F
where A: Tuple, F: Fn<A>, F: ?Sized;
- impl<Args, F, A> Fn<Args> for Box<F, A>
where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized;
- impl<F, Args> Fn<Args> for Exclusive<F>
Expand Down
Loading