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 upCan't write non-overlapping blanket impls that involve associated type bindings #20400
Comments
kmcallister
added
A-traits
A-associated-items
labels
Jan 16, 2015
This comment has been minimized.
This comment has been minimized.
|
I encountered this bug too, while trying to optimize pub enum Void {}
pub trait Display {
// ...
type AsStr = Void;
fn fmt_as_str(&self) -> &<Self as Display>::AsStr { unimplemented!() }
}
pub trait ToString {
fn to_string(&self) -> String;
}
impl<T: Display<AsStr=Void> + ?Sized> ToString for T {
fn to_string(&self) -> String {
format!("{}", self)
}
}
impl<T: Display<AsStr=str> + ?Sized> ToString for T {
fn to_string(&self) -> String {
String::from_str(self.fmt_as_str())
}
}This change could speed up |
This was referenced Jan 30, 2015
This comment was marked as resolved.
This comment was marked as resolved.
|
cc me |
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
|
cc me |
cristicbz
referenced this issue
Mar 13, 2015
Closed
Can't provide non-overlapping trait impls based on assoc type trait bound #23341
This comment has been minimized.
This comment has been minimized.
|
This is really causing problems for a crate I'm working on. |
This comment has been minimized.
This comment has been minimized.
|
Is this bug likely to get any love? I keep hitting this (see #23341) too. I had a look around by I can't really follow how overlapping impls are determined, I would have liked to have a go at it. |
sgrif
referenced this issue
Dec 3, 2015
Closed
Can't provide non-overlapping impls with *any* type parameters, if a blanket impl exists #30191
This comment has been minimized.
This comment has been minimized.
|
Any chance of this getting triaged any time soon? Also feeling pains from this issue. |
sgrif
added a commit
to diesel-rs/diesel
that referenced
this issue
Jan 18, 2016
kylewlacy
referenced this issue
May 24, 2016
Open
Tracking issue for specialization (RFC 1210) #31844
Diggsey
referenced this issue
May 1, 2017
Closed
Conflicting impls if type parameter is bounded by associated types #41680
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
May 1, 2017
|
I ran into this problem just now. I wanted to provide |
Mark-Simulacrum
added
the
C-bug
label
Jul 22, 2017
dtolnay
referenced this issue
Aug 13, 2018
Closed
Associated Type bounds not checked when checking for conflicting implementations of traits #52912
This comment has been minimized.
This comment has been minimized.
ZerothLaw
commented
Aug 13, 2018
|
What's needed to advance this issue towards a fix? Are we dependent on Chalk? |
This comment has been minimized.
This comment has been minimized.
ZerothLaw
commented
Aug 13, 2018
|
Looks like you can kind of "trick" the compiler by using type specialization. On stable, 2015 edition: |
arielb1
referenced this issue
Dec 14, 2018
Closed
Is this on purpose? -- Conflicting Impl Check #56804
This comment has been minimized.
This comment has been minimized.
|
I'd like to add myself to the list of people that this causes problems for :). |
dbeckwith
referenced this issue
Feb 4, 2019
Open
Error duplicate definitions for impls on distinct associated types #58171
This comment has been minimized.
This comment has been minimized.
dbeckwith
commented
Feb 4, 2019
@ZerothLaw could you explain your trick a bit? I think I'm running into this issue and am hoping for a workaround but I'm struggling to understand your example. If you could give some advice on how to apply that to the code in #58171 that would be great. |
japaric commentedJan 1, 2015
STR
Example from libcore:
Version
7d4f487
No type can implement both
Iterator<Item=u8>andIterator<Item=u16>, therefore these blanket impls are non overlapping and should be accepted.cc @nikomatsakis