Open
Description
Edit: outstanding case:
struct S<T: Copy>(T);
fn main() {
let _: S<String>;
}
Generic Arguments
fn main() {
let _ = Option::<[u8]>::None;
}
Stderr:
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/main.rs:2:13
|
2 | let _ = Option::<[u8]>::None;
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
note: required by a bound in `None`
Ideally, it should be:
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/main.rs:2:13
|
2 | let _ = Option::<[u8]>::None;
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
note: required by a bound in `None`
GAT Arguments Specifically
Given the following code:
struct S;
trait D {
type P<T: Copy>;
}
impl D for S {
type P<T: Copy> = ();
}
fn main() {
let _: <S as D>::P<String>;
}
The current output is:
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/main.rs:9:12
|
9 | let _: <S as D>::P<String>;
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
Ideally the output should look like:
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/main.rs:9:12
|
9 | let _: <S as D>::P<String>;
| ^^^^^^ the trait `Copy` is not implemented for `String`
The span is misleading because at first sight one might think that the compiler claimed that the projected type ()
ddid not implement Copy
. In this simplified case, it's quite easy to see what's going on (especially after reading the message and the label) but I bet in more complex scenarios involving several type parameters and more complicated bounds, it's much more difficult to decipher the diagnostic.