Add missing impl Fn for &mut F where F: Fn#148271
Add missing impl Fn for &mut F where F: Fn#148271Kivooeo wants to merge 1 commit intorust-lang:mainfrom
impl Fn for &mut F where F: Fn#148271Conversation
|
@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.
Is this "since" line correct?
There was a problem hiding this comment.
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.
What do you mean by "should be available on all versions"?
There was a problem hiding this comment.
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.
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.
oh, ok then, I will change it after crater
There was a problem hiding this comment.
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.
it don't feel correct to change stable since for all impls
There was a problem hiding this comment.
What you've done might be fine, I've seen other PRs that just re-use an existing stable feature name and version for small gaps like this.
But for other PRs, if you want to declare them stable in the version where the PR merges, use:
| #[stable(feature = "rust1", since = "1.0.0")] | |
| #[stable(feature = "new_feature_name", since = "CURRENT_RUSTC_VERSION")] |
This does two things:
- makes the "consistent feature stable version" check pass (because it's a new feature)
- when the code is promoted to beta, CURRENT_RUSTC_VERSION will automatically get replaced with the current version
https://std-dev-guide.rust-lang.org/development/stabilization.html#stabilization-pr-checklist
|
@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
Desugaring of call expressions into There's a special case baked in to handle direct closure invocations, but not for invocations of types that contain closures. This is tracked at #38305. So basically the lack of this impl allowed you to bypass this bug in some cases, and adding it makes it resurface. |
|
☔ The latest upstream changes (presumably #146923) made this pull request unmergeable. Please resolve the merge conflicts. |
|
hi, checking progress. Is this still waiting on a T-types discussion? thanks for an update :) |
from the types nomination |
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