rust/tests/ui/sized/coinductive-2.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
499 B
Rust
Raw Normal View History

2021-03-29 15:32:20 +00:00
//@ run-pass
struct Node<C: CollectionFactory<Self>> {
_children: C::Collection,
}
trait CollectionFactory<T> {
type Collection;
}
impl<T> CollectionFactory<T> for Vec<()> {
type Collection = Vec<T>;
}
2024-02-07 02:42:01 +00:00
trait Collection<T>: Sized { //~ WARN trait `Collection` is never used
2021-03-29 15:32:20 +00:00
fn push(&mut self, v: T);
}
impl<T> Collection<T> for Vec<T> {
fn push(&mut self, v: T) {
self.push(v)
}
}
fn main() {
let _ = Node::<Vec<()>> {
_children: Vec::new(),
};
}