-
Notifications
You must be signed in to change notification settings - Fork 14k
Add missing impl Fn for &mut F where F: Fn
#148271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
Add missing `impl Fn for &mut F where F: Fn`
|
r? libs-api |
| } | ||
| } | ||
|
|
||
| #[stable(feature = "rust1", since = "1.0.0")] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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")]
| There was a problem hiding this comment.
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
|
@craterbot run mode=check-only |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
@craterbot run mode=check-only crates=https://crater-reports.s3.amazonaws.com/pr-148271/retry-regressed-list.txt p=1 |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
The only non-spurious failure was from the #![feature(unboxed_closures)]
#![feature(fn_traits)]
#[allow(dead_code)]
pub struct Curried<F> {
func: F,
}
impl<F: FnOnce()> FnOnce<()> for Curried<F> {
type Output = ();
extern "rust-call" fn call_once(self, _: ()) {}
}
impl<F: FnMut()> FnMut<()> for Curried<F> {
extern "rust-call" fn call_mut(&mut self, _: ()) {}
}
impl<F: Fn()> Fn<()> for Curried<F> {
extern "rust-call" fn call(&self, _: ()) {}
}
pub fn test_mut() {
let mut i = 0;
let mut f = || {
i += 1;
};
let mut fj = Curried { func: &mut f };
fj();
}Error after this PR: I don't understand why it's erroring though... |
|
gonna nominate this for T-types. I am not sure to what extent we actually depend on the exact set of |
|
can you add |
|
@programmerjake, I have zero understanding of what is happening in async code, is this correct impl (I just copied from 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)
}
}For context: https://doc.rust-lang.org/src/core/ops/async_function.rs.html#60 |
it looks correct to me |
119ae33 to
77295f7
Compare
Currently, there are blanket implementations for
&Fand&mut FforFnMutandFnOnce, but not forFn, as a result,&mut Fimplements fewer of theFntraits than&F, which is inconsistent and this PR fills that coherence holeTechnically, this is a breaking change because Fn is a fundamental trait, however, practical breakage is expected to be minimal, as such overlapping impl patterns are extremely rare
Because of this, second
implfor&mut fn()works fine but shouldn'tFixes #147931