-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsized types allowed in trait method declarations and default type parameters #19182
Comments
This is also the case for supertrait bounds: trait Foo<T> {}
trait Bar : Foo<[u8]> {} |
This also compiles, though fn foo(_: [u8]) {} |
Another one ( type Foo = Vec<[u8]>; |
There are actually two issues here, as I see it:
Perhaps this issue should be split into two issues, then? I think this issue should be repurposed for the DST-related part (part 2), and a new issue should be created for the other part (unless such an issue already exists). |
@nikomatsakis claims this is intentional. |
closing. |
@nikomatsakis Why is this intentional behavior? The following code still compiles on Rust 1.50: trait Foo {
fn bar(a: [u8]);
fn baz() -> [u8];
} |
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)
:Attempting to implement
Foo
or provide a default implementation forbar
orbaz
results in the expected compilation error per #13376.Note that
T
is not declaredSized?
. Attempting to explicitly instantiate this type parameter with an unsized type results in the expected compilation error for each of these cases.The text was updated successfully, but these errors were encountered: