fix: suppress from_over_into when blanket From impl would conflict#16835
fix: suppress from_over_into when blanket From impl would conflict#16835barry3406 wants to merge 1 commit intorust-lang:masterfrom
from_over_into when blanket From impl would conflict#16835Conversation
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
|
r? @dswij rustbot has assigned @dswij. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
|
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 |
Fixes #16823
When a type has a generic
Fromimpl like:The
from_over_intolint would suggest convertingimpl Into<String> for Footoimpl 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'simpl<T> From<T> for T.Before: lint fires, suggestion doesn't compile
After: lint correctly suppressed, no false positive
The fix checks whether the self type has any
Fromimpl where the source type is a bare generic parameter (likeimpl<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 suggestFromconversion when a genericFromimpl would cause a coherence conflict