Closed as not planned
Closed as not planned
Description
See the following code
use std::borrow::Cow;
// Does not work either: #[derive(Clone)]
enum Foo<'a> {
// Does not work:
Bar(Cow<'a, [Foo<'static>]>),
// Works: Bar(Vec<Foo<'a>>),
Baz(&'a str),
}
impl<'a> Clone for Foo<'a> {
fn clone(&self) -> Self {
unimplemented!();
}
}
fn main() {}
This currently fails to compile with
error[E0275]: overflow evaluating the requirement `<[Foo<'a>] as std::borrow::ToOwned>::Owned`
--> test.rs:5:9
|
5 | Bar(Cow<'a, [Foo<'a>]>),
| ^^^^^^^^^^^^^^^^^^^
|
= note: required because it appears within the type `Foo<'a>`
= note: required because of the requirements on the impl of `std::borrow::ToOwned` for `[Foo<'a>]`
= note: required because it appears within the type `std::borrow::Cow<'a, [Foo<'a>]>`
= note: only the last field of a struct may have a dynamically sized type
However in the end the Cow here is just an enum that is either a &[Foo] or a Vec (the ToOwned instance of [T] uses Vec for the owned variant), both having a known size and thus this all should really work, or am I missing something?
Is this a bug, a missing feature or can't this possibly work?