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 upTrait-objects need associated-types of subtraits to be specified even when that's already done by the boxed trait #29328
Comments
qrlpx
changed the title
In trait-object-types, associated-types of subtraits need to be specified even when that's already done by the boxed trait
Trait-objects need associated-types of subtraits to be specified even when that's already done by the boxed trait
Oct 26, 2015
steveklabnik
added
the
A-traits
label
Oct 26, 2015
This comment has been minimized.
This comment has been minimized.
|
I would like to claim that this is a part of "non-supertrait predicates are not elaborated", but this quite ugly. However, with the current acyclicity requirements, this would break stuff like trait Foo : Iterator where Self::Item: Copy {}Maybe just give them the |
This comment has been minimized.
This comment has been minimized.
|
I just hit this issue and discovered this bug by searching. I don't understand most of the words in the comment explaining why this behavior is this way. :-) But it's definitely a weird UX issue, in that it's not at all obvious to a user why it would do this. |
apasel422
referenced this issue
Nov 25, 2015
Closed
Trait objects require redundantly specifying associated types #30056
This comment has been minimized.
This comment has been minimized.
Wyverald
commented
Dec 20, 2015
|
This also makes it hard to parameterize associated types. trait Foo { type Bar; }
trait Foobar<T> : Foo<Bar=T> {}
struct Quux<'a> {
foobar: &'a Foobar<String>,
}That doesn't compile. I'll need to write |
This comment has been minimized.
This comment has been minimized.
|
In combination with Fn traits, this seems like a hole in stability! Check out this code: trait FnAlias: Fn() {}
fn main() {
let _: FnAlias; // error
let _: FnAlias<Output=()>; // no error, but I shouldn't be able to do this!
}Normally I can't write an Fn trait while specifying the return type as an associated type, at least without |
This comment has been minimized.
This comment has been minimized.
bstrie
added
the
A-stability
label
May 2, 2016
This comment has been minimized.
This comment has been minimized.
|
Tagging with A-stability based on durka's comment. |
aturon
added
I-nominated
T-lang
T-libs
labels
May 2, 2016
alexcrichton
added
T-compiler
and removed
T-lang
T-libs
labels
May 4, 2016
This comment has been minimized.
This comment has been minimized.
|
So while it's true that this bug allows you to name the |
This comment has been minimized.
This comment has been minimized.
|
In particular, we are more concerned about the input argument types, which may want to become variadic or otherwise change. |
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium |
rust-highfive
added
P-medium
and removed
I-nominated
labels
May 5, 2016
This comment has been minimized.
This comment has been minimized.
|
Closing as dup of #24010 |
qrlpx commentedOct 26, 2015
If someone has a shorter/more conclusive title in mind, shoot.
code
Playpen: http://is.gd/6QKndB
output
rustc version