-
Notifications
You must be signed in to change notification settings - Fork 13.3k
conflicting implementations when attempting to impl<S> Into<S> for ArbitraryStructWithNoOtherImpls<S>
#27403
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
In your example, the compiler can't prove that S doesn't implement I agree with your assessment of the diagnostic. |
@eefriedman I suppose in that case I'd consider the conflict to come from the provider of the It might be helpful to note that with the current way the compiler thinks about things, Edit: note, I haven't thought about the above enough to know if it is possible. Edit2: and just realized that the behavior I'm looking for in the first paragraph is similar in functionality to negative trait bounds. |
Op compiles successfully today. |
Just add a test case. |
One of the examples does compile, but the issue was reported about a different example which doesn't. Not E-needstest; not sure that I follow what could change with the diagnostic though. pub struct GenX<S> {
inner: S,
}
impl<S> Into<S> for GenX<S> {
fn into(self) -> S {
self.inner
}
}
fn main() {
println!("HI");
} |
…sakis Improve diagnostic of E0119 with extern crate, try to print the conflicting impl. Closes #27403. Closes #23563. Should improve #23980. The diagnostic now looks like: ``` error[E0119]: conflicting implementations of trait `std::convert::Into<_>` for type `GenX<_>`: --> $DIR/issue-27403.rs:15:1 | 15 | / impl<S> Into<S> for GenX<S> { 16 | | fn into(self) -> S { 17 | | self.inner 18 | | } 19 | | } | |_^ | = note: conflicting implementation in crate `core`: - impl<T, U> std::convert::Into<U> for T where U: std::convert::From<T>; error: aborting due to previous error ```
At the very least (if this failure is expected), the error needs to be improved to actually point to the conflicting impl rather than simply printing the crate name and repeating the same function output that conflicts (if it is for some reason not possible to print better info about the previously declared conflicting impl, at the very least the compiler should stop repeating the output for the impl generating the error). On the diagnostics side, this appears related to #27218.
Note that simply changing the struct (in this case,
GenX<T>
) to a non-generic struct allows the build to proceed without issue (example: http://is.gd/lRAhBF).It appears that somehow the
impl<T, U> Into<U> for T where U: From<T>
is considered to be conflicting with allInto<U>
impls whereU
is a generic parameter even in cases whereU
does not implFrom<T>
.error:
source:
playpen: http://is.gd/zrwjve
The text was updated successfully, but these errors were encountered: