Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upconflicting implementations when attempting to `impl<S> Into<S> for ArbitraryStructWithNoOtherImpls<S>` #27403
Comments
This comment has been minimized.
This comment has been minimized.
|
In your example, the compiler can't prove that S doesn't implement I agree with your assessment of the diagnostic. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
steveklabnik
added
the
A-diagnostics
label
Aug 4, 2015
brson
added
T-lang
P-low
labels
Jan 26, 2017
This comment has been minimized.
This comment has been minimized.
|
Op compiles successfully today. |
brson
added
the
E-needstest
label
Jan 26, 2017
This comment has been minimized.
This comment has been minimized.
|
Just add a test case. |
steveklabnik
removed
the
T-compiler
label
Mar 9, 2017
This comment has been minimized.
This comment has been minimized.
|
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");
} |
jmesmon commentedJul 30, 2015
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 whereUis a generic parameter even in cases whereUdoes not implFrom<T>.error:
source:
playpen: http://is.gd/zrwjve