diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-09-16 11:17:02 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-16 11:17:02 +0530 |
| commit | cfef659d137e0491c3a1356ffd4dbd2968c18404 (patch) | |
| tree | 766e2d048e79ce3fdda2a8efaf6d91095c5889d3 | |
| parent | 28b4c62382988b895e505698289939f71248626f (diff) | |
| parent | 478c471ce8aabb07e115f4caa18f4f1ca9acbc49 (diff) | |
| download | rust-cfef659d137e0491c3a1356ffd4dbd2968c18404.tar.gz rust-cfef659d137e0491c3a1356ffd4dbd2968c18404.zip | |
Rollup merge of #101802 - chriss0612:const_fn_trait_ref_impls, r=fee1-dead
Constify impl Fn* &(mut) Fn* Tracking Issue: [101803](https://github.com/rust-lang/rust/issues/101803) Feature gate: `#![feature(const_fn_trait_ref_impls)]` This feature allows using references to Fn* Items as Fn* Items themself in a const context.
| -rw-r--r-- | library/core/src/ops/function.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index c5a194b7d0a..8fdf22cf6f2 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -250,9 +250,10 @@ pub trait FnOnce<Args> { mod impls { #[stable(feature = "rust1", since = "1.0.0")] - impl<A, F: ?Sized> Fn<A> for &F + #[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")] + impl<A, F: ?Sized> const Fn<A> for &F where - F: Fn<A>, + F: ~const Fn<A>, { extern "rust-call" fn call(&self, args: A) -> F::Output { (**self).call(args) @@ -260,9 +261,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A, F: ?Sized> FnMut<A> for &F + #[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")] + impl<A, F: ?Sized> const FnMut<A> for &F where - F: Fn<A>, + F: ~const Fn<A>, { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { (**self).call(args) @@ -270,9 +272,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A, F: ?Sized> FnOnce<A> for &F + #[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")] + impl<A, F: ?Sized> const FnOnce<A> for &F where - F: Fn<A>, + F: ~const Fn<A>, { type Output = F::Output; @@ -282,9 +285,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A, F: ?Sized> FnMut<A> for &mut F + #[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")] + impl<A, F: ?Sized> const FnMut<A> for &mut F where - F: FnMut<A>, + F: ~const FnMut<A>, { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { (*self).call_mut(args) @@ -292,9 +296,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A, F: ?Sized> FnOnce<A> for &mut F + #[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")] + impl<A, F: ?Sized> const FnOnce<A> for &mut F where - F: FnMut<A>, + F: ~const FnMut<A>, { type Output = F::Output; extern "rust-call" fn call_once(self, args: A) -> F::Output { |
