-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Conflicting implementations with fn_traits
and From
#142037
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
Comments
Here's a reproduction of this without using the Fn traits: struct Thing;
trait Trait {}
impl<T: Trait> From<T> for Thing {
fn from(_: T) -> Thing {
Thing
}
}
// Uncomment this to see the conflict
// impl Trait for Thing {} I think this is working as intended. Rust is using the fact that |
I think this is expected, and unrelated to Example without #![allow(unused)]
struct MyFoo;
impl Clone for MyFoo {
fn clone(&self) -> Self { unimplemented!() }
}
// // Uncomment this to see the conflict From<F> implementation makes
// impl Copy for MyFoo {}
// When MyFn implements Copy
// From<F> will also
// impl From<MyFoo> for MyFoo {}
impl<F> From<F> for MyFoo
where
F: Copy,
{
fn from(f: F) -> Self { unimplemented!() }
} when
Also, (though I don't think it noticably affects the logic in this case) the |
You are absolutely right! |
I was hoping you could, nudge me |
// Hypothetical solution, which does not exist
#![allow(unused)]
struct MyFoo;
trait Marked {}
impl Marked for MyFoo { }
impl Clone for MyFoo {
fn clone(&self) -> Self { unimplemented!() }
}
impl<F> From<F> for MyFoo
where
F: Clone + !Marked,
{
fn from(f: F) -> Self { unimplemented!() }
}
// Not to be allowed to be used alone
// impl<F: !Marked> From<F> for MyFoo {} // disallowed
// Using !Marked to be limited to the crate
// where Marked is defined or even more strictly
// to the module. |
I think even with those limitations |
From the link @zachs18 provided https://rust-lang.github.io/rfcs/1023-rebalancing-coherence.html |
The text was updated successfully, but these errors were encountered: