Closed
Description
It appears that the rules for where unsized types may appear are inconsistently enforced. This doesn't appear to cause unsoundness, because the items are unusable, but an early error would probably be helpful.
The following snippets compile with rustc 0.13.0-nightly (399ff259e 2014-11-20 00:27:07 +0000)
:
trait Foo {
fn bar(a: [u8]);
fn baz() -> [u8];
}
Attempting to implement Foo
or provide a default implementation for bar
or baz
results in the expected compilation error per #13376.
#![feature(default_type_params)]
trait Foo<T = [u8]> {}
struct Bar<T = [u8]>;
enum Baz<T = [u8]> {}
fn quux<T = [u8]>() {}
Note that T
is not declared Sized?
. Attempting to explicitly instantiate this type parameter with an unsized type results in the expected compilation error for each of these cases.