Skip to content

fix: suppress from_over_into when blanket From impl would conflict#16835

Open
barry3406 wants to merge 1 commit intorust-lang:masterfrom
barry3406:fix/from-over-into-blanket-conflict
Open

fix: suppress from_over_into when blanket From impl would conflict#16835
barry3406 wants to merge 1 commit intorust-lang:masterfrom
barry3406:fix/from-over-into-blanket-conflict

Conversation

@barry3406
Copy link
Copy Markdown

@barry3406 barry3406 commented Apr 9, 2026

Fixes #16823

When a type has a generic From impl like:

impl<T> From<T> for Foo where String: From<T> { ... }

The from_over_into lint would suggest converting impl Into<String> for Foo to impl From<Foo> for String. But that causes a coherence conflict (E0119) because it makes the blanket impl's where clause satisfiable, which overlaps with core's impl<T> From<T> for T.

Before: lint fires, suggestion doesn't compile

warning: an implementation of `From` is preferred since it gives you `Into<_>` for free
  --> src/lib.rs:13:1
   |
13 | impl Into<String> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: replace the `Into` implementation with `From<Foo>`

After: lint correctly suppressed, no false positive

The fix checks whether the self type has any From impl where the source type is a bare generic parameter (like impl<T> From<T> for Foo). If so, the lint is skipped.

Added a test case with the exact reproducer from the issue.

changelog: [from_over_into]: don't suggest From conversion when a generic From impl would cause a coherence conflict

Don't suggest converting `impl Into<T> for Foo` to `impl From<Foo> for T`
when `Foo` has a generic `From` impl like `impl<T> From<T> for Foo where ...`.

The suggested conversion could create a coherence conflict with the core
`impl<T> From<T> for T` blanket impl by satisfying a where clause that
makes two From impls overlap.

Fixes rust-lang#16823
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 9, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 9, 2026

r? @dswij

rustbot has assigned @dswij.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 9, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Apr 11, 2026

Hi,

For the last few months we have been receiving an increased amount of slop by users running bots that generate contributions, and even misconfiguring their bot so it will even send generated apology emails on top. We have no way to distinguish your PR from your other generated ones and no way to determine whether you actually want to contribute.

We are a community of contributors, not just a code repository. Thus we focus on contributors who desire to stay around and put in the work to produce high quality contributions or learn to do so.

We are thus banning you as per our policies (1) and contribution standards (2). You can contact the moderation team to discuss and possibly reconsider your ban.

Thanks for understanding

Oli in the name of the mod team

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

from_over_into suggests turning Into into conflicting From

4 participants