Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d9a00dc0e329f0ea73b037f3af9f26db
use std::marker::PhantomData;
trait Trait {}
struct Unsized([u8], ());
struct Foo<T: ?Sized>(PhantomData<T>);
impl<T> Trait for Foo<T> {}
impl Trait for Foo<Unsized> {}
The current output is:
error[E0119]: conflicting implementations of trait `Trait` for type `Foo<Unsized>`:
--> src/main.rs:9:1
|
8 | impl<T> Trait for Foo<T> {}
| ------------------------ first implementation here
9 | impl Trait for Foo<Unsized> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<Unsized>`
Ideally the output should look like:
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/lib.rs:1:16
|
5 | struct Unsized([u8], ());
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= note: only the last field of a struct may have a dynamically sized type
= help: change the field's type to have a statically known size
help: borrowed types always have a statically known size
|
5 | struct Unsized(&[u8], ());
| ^
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
5 | struct Unsized(Box<[u8]>, ());
| ^^^^ ^
error: aborting due to previous error
Note: this error is particularly confusing because the trait impls *dont* overlap after fixing the field ordering error
cc @estebank
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d9a00dc0e329f0ea73b037f3af9f26db
The current output is:
Ideally the output should look like:
Note: this error is particularly confusing because the trait impls *dont* overlap after fixing the field ordering error
cc @estebank