Skip to content

Commit ba10458

Browse files
Merge conflicts and rebase onto master
1 parent f4722e0 commit ba10458

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

core/src/const_closure.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use crate::marker::Destruct;
2+
#[cfg(not(bootstrap))]
3+
use crate::marker::Tuple;
24

35
/// Struct representing a closure with mutably borrowed data.
46
///
@@ -44,6 +46,7 @@ impl<'a, CapturedData: ?Sized, Function> ConstFnMutClosure<&'a mut CapturedData,
4446

4547
macro_rules! impl_fn_mut_tuple {
4648
($($var:ident)*) => {
49+
#[cfg(bootstrap)]
4750
#[allow(unused_parens)]
4851
impl<'a, $($var,)* ClosureArguments, Function, ClosureReturnValue> const
4952
FnOnce<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
@@ -56,6 +59,7 @@ macro_rules! impl_fn_mut_tuple {
5659
self.call_mut(args)
5760
}
5861
}
62+
#[cfg(bootstrap)]
5963
#[allow(unused_parens)]
6064
impl<'a, $($var,)* ClosureArguments, Function, ClosureReturnValue> const
6165
FnMut<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
@@ -68,6 +72,32 @@ macro_rules! impl_fn_mut_tuple {
6872
(self.func)(($($var),*), args)
6973
}
7074
}
75+
#[cfg(not(bootstrap))]
76+
#[allow(unused_parens)]
77+
impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const
78+
FnOnce<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
79+
where
80+
Function: ~const Fn(($(&mut $var),*), ClosureArguments) -> ClosureReturnValue+ ~const Destruct,
81+
{
82+
type Output = ClosureReturnValue;
83+
84+
extern "rust-call" fn call_once(mut self, args: ClosureArguments) -> Self::Output {
85+
self.call_mut(args)
86+
}
87+
}
88+
#[cfg(not(bootstrap))]
89+
#[allow(unused_parens)]
90+
impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const
91+
FnMut<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
92+
where
93+
Function: ~const Fn(($(&mut $var),*), ClosureArguments)-> ClosureReturnValue,
94+
{
95+
extern "rust-call" fn call_mut(&mut self, args: ClosureArguments) -> Self::Output {
96+
#[allow(non_snake_case)]
97+
let ($($var),*) = &mut self.data;
98+
(self.func)(($($var),*), args)
99+
}
100+
}
71101
};
72102
}
73103
impl_fn_mut_tuple!(A);

core/src/ops/function.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ use crate::marker::Tuple;
7575
)]
7676
#[fundamental] // so that regex can rely that `&str: !FnMut`
7777
#[must_use = "closures are lazy and do nothing unless called"]
78-
#[cfg_attr(not(bootstrap), const_trait)]
7978
pub trait Fn<Args>: FnMut<Args> {
8079
/// Performs the call operation.
8180
#[unstable(feature = "fn_traits", issue = "29625")]
@@ -245,7 +244,6 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
245244
)]
246245
#[fundamental] // so that regex can rely that `&str: !FnMut`
247246
#[must_use = "closures are lazy and do nothing unless called"]
248-
#[cfg_attr(not(bootstrap), const_trait)]
249247
pub trait FnMut<Args>: FnOnce<Args> {
250248
/// Performs the call operation.
251249
#[unstable(feature = "fn_traits", issue = "29625")]
@@ -415,7 +413,6 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
415413
)]
416414
#[fundamental] // so that regex can rely that `&str: !FnMut`
417415
#[must_use = "closures are lazy and do nothing unless called"]
418-
#[cfg_attr(not(bootstrap), const_trait)]
419416
pub trait FnOnce<Args> {
420417
/// The returned type after the call operator is used.
421418
#[lang = "fn_once_output"]

0 commit comments

Comments
 (0)