-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Cannot call by reference to &mut F: FnMut
#112808
Labels
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Pretty sure that it's due to this hack 😓 rust/compiler/rustc_hir_typeck/src/callee.rs Lines 180 to 194 in 4051305
We really should be re-trying that branch if the other autoderef steps fail. rust/compiler/rustc_hir_typeck/src/callee.rs Lines 96 to 98 in 4051305
|
Another workaround, probably more effecient: fn call_by_anonymising<F, A0, A1>(mut f: F, arg0: A0, arg1: A1)
where
A0: Sized,
A1: Sized,
for<'w> &'w mut F: FnMut(A0, A1),
{
#[inlne]
fn anonymise<B0, B1>(f: impl FnOnce(B0, B1))->impl FnOnce(B0, B1){
f
}
// This works
anonymise(&mut f)(arg0, arg1);
} |
ChrisDenton
added
the
needs-triage-legacy
Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged.
label
Jul 16, 2023
Enselic
added
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triage-legacy
Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged.
labels
Jul 30, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: Both functions should compile and work.
Instead, this happened: Only version with inner function hack works.
Meta
rustc --version --verbose
:AFAIK, it never worked.
The text was updated successfully, but these errors were encountered: