rust-lang / rust-lang/rust

`&mut impl Fn()` does not implement `Fn()`

Open
#147,931 4 comments 2 reactions 1 assignee View on GitHub

@Kivooeo is already working on this.

Since Oct 21, 2025.

A-closures C-bug T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

There are the following blanket implementations of the Fn traits on reference types (abbreviated to omit the argument type):

  • impl Fn for &F where F: Fn
  • impl FnMut for &F where F: Fn
  • impl FnOnce for &F where F: Fn
  • impl FnMut for &mut F where F: FnMut
  • impl FnOnce for &mut F where F: FnMut

The following blanket implementation is possible to implement, but is missing from the standard library:

  • impl Fn for &mut F where F: Fn

As far as I can tell, this blanket impl was overlooked in the initial implementation.

This leads to a weird situation where &mut F implements fewer of the Fn traits than &F. This is somewhat strange.

I'm not sure if this needs to be fixed though, since I can't come up with a realistic use case that would run into this.

I am unsure if this is a breaking change or not, as this is a new implementation of a fundamental trait on a fundamental type. I am unable to find code that compiles in stable rust that would break from this change though.

Meta

Affects stable rust version 1.90.0.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.