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 upInconsistent constraint validation on derived trait specializations with associated types #22675
Comments
This comment has been minimized.
This comment has been minimized.
|
Example desired use in program:
|
This comment has been minimized.
This comment has been minimized.
|
I believe this is a non-issue. In the given example, the first two are traits, |
This comment has been minimized.
This comment has been minimized.
|
Ok but then any suggestion as to how to express that
|
This comment has been minimized.
This comment has been minimized.
|
One thing I don't understand about your design is why use std::marker::PhantomFn;
trait TTrans : PhantomFn<(Self)> { type O; }
type ApplyT<T> = <T as TTrans>::O;
trait Reusable<H> {
type E;
fn ap<R, F : Fn(Self::E)->R>(self, f : F) -> ApplyT<H>;
}
trait Other<H> {
type E;
fn ap2<R, F : Fn(Self::E)->R>(self, f : F) -> ApplyT<H>;
}
impl<H,T> Reusable<H> for T where T : Other<H> , H : TTrans {
type E = <Self as Other<H> >::E;
fn ap<R, F : Fn(<Self as Other<H>>::E)->R>(self, f : F) -> ApplyT<H> {
self.ap2(f)
}
}
fn main() {} |
This comment has been minimized.
This comment has been minimized.
|
Thanks Edward for taking the time to look at this. I believe that the idea to pass the handle to the trait as parameter ( |
This comment has been minimized.
This comment has been minimized.
|
Well, you could let struct Option_<T> { _marker: PhantomData<T> }Anyway, I don't think a ticket is the right place to continue this discussion. You may want to try http://internals.rust-lang.org/ instead. |
steveklabnik
added
the
A-typesystem
label
Feb 23, 2015
This comment has been minimized.
This comment has been minimized.
|
Triage: it seems that the original filing here was more of a feature request than a bug, or rather, it's not clear that it's a bug. |
knz commentedFeb 22, 2015
In the code below, rustc should either reject all 3 uses of ApplyT, or none. Currently it only rejects the 3rd one, which is inconsistent:
Note that in all 3 uses of ApplyT, the first parameter H is open. Intuition would dictate that rustc should delay checking whether ApplyT<H,R> is valid until H is known. However, rustc inconsistently does so: the first 2 uses of ApplyT cause no error (suggesting the check is indeed delayed), while the last generates an error:
Of course it would be best if the 3rd case would be delayed as well, but if for any reason that proves difficult, at least for the sake of consistency the behavior should be the same in all 3 cases.
Meta