Skip to content

Conversation

@Kivooeo
Copy link
Member

@Kivooeo Kivooeo commented Oct 29, 2025

Currently, there are blanket implementations for &F and &mut F for FnMut and FnOnce, but not for Fn, as a result, &mut F implements fewer of the Fn traits than &F, which is inconsistent and this PR fills that coherence hole

Technically, 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

pub trait Trait {} impl<F: Fn()> Trait for F {} impl Trait for &fn() {} // not allowed impl Trait for &mut fn() {} // allowed

Because of this, second impl for &mut fn() works fine but shouldn't

Fixes #147931

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Oct 29, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 29, 2025

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Noratrieb Noratrieb added the needs-crater This change needs a crater run to check for possible breakage in the ecosystem. label Oct 29, 2025
@Noratrieb
Copy link
Member

@bors try

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 29, 2025
Add missing `impl Fn for &mut F where F: Fn`
@Noratrieb
Copy link
Member

r? libs-api

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Oct 29, 2025
@rustbot rustbot assigned the8472 and unassigned scottmcm Oct 29, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 30, 2025

☀️ Try build successful (CI)
Build commit: ddcf048 (ddcf048784667508cd676fef4667f88ae15628a3, parent: 292be5c7c05138d753bbd4b30db7a3f1a5c914f7)

@theemathas theemathas added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Oct 30, 2025
@saethlin
Copy link
Member

@craterbot run mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-148271 created and queued.
🤖 Automatically detected try build ddcf048
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2025
@craterbot
Copy link
Collaborator

🚧 Experiment pr-148271 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-crater This change needs a crater run to check for possible breakage in the ecosystem. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-crater Status: Waiting on a crater run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

8 participants