Closed
Description
I tried this code:
#![feature(generic_associated_types)]
trait Allocator {
type Allocated<T>;
}
enum LinkedList<A: Allocator> {
Head,
Next(A::Allocated<Self>)
}
fn main() {}
I expected to see this happen: Enum successfully compiles and can be constructed.
Instead, this happened:
error[E0275]: overflow evaluating the requirement '<A as Allocator>::Allocated<CLinkedList<A>>: Sized'
Interestingly, this compiles:
#![feature(generic_associated_types)]
trait Allocator {
type Allocated<T>;
}
enum CLinkedList<A: Allocator> {
Head,
Next(A::Allocated<Self>, i64)
}
fn main() {}
As does this:
#![feature(generic_associated_types)]
trait Allocator {
type Allocated<T>;
}
struct LinkedListStruct<A: Allocator> {
value: i64,
next: Option<A::Allocated<Self>>
}
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.51.0-nightly (17eec1433 2021-01-01)
binary: rustc
commit-hash: 17eec1433c69972844dd228b5fe801f218e118c3
commit-date: 2021-01-01
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly