Open
Description
Code:
trait Trait {}
struct Unsized {
tail: [()],
marker: (),
}
impl<T: Sized> Trait for T {}
impl Trait for Unsized {}
error:
error[E0119]: conflicting implementations of trait `Trait` for type `Unsized`:
--> src/lib.rs:10:1
|
9 | impl<T: Sized> Trait for T {}
| -------------------------- first implementation here
10 | impl Trait for Unsized {}
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Unsized`
Without impl Trait for Unsized
:
error[E0277]: the size for values of type `[()]` cannot be known at compilation time
--> src/lib.rs:4:5
|
4 | tail: [()],
| ^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[()]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: only the last field of a struct may have a dynamically sized type
The better behavior would be to
- Make sure that the E0277 is emitted even in the case of other errors.
- When finding an E0277 struct definition, treat it as if it were
?Sized
through the rest of the pipeline.