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.
Activity
[-]Diagnostic points at whole path instead of type argument if the latter does not satisfy a trait bound[/-][+]Diagnostic points at whole path instead of type argument of a GAT if the latter does not satisfy a trait bound[/+][-]Diagnostic points at whole path instead of type argument of a GAT if the latter does not satisfy a trait bound[/-][+]Diagnostic points at whole path instead of a GAT argument if the latter does not satisfy a trait bound[/+][-]Diagnostic points at whole path instead of a GAT argument if the latter does not satisfy a trait bound[/-][+]Diagnostic points at whole path instead of GAT argument if the latter does not satisfy a trait bound[/+]where
clause when an obligation is unsatisfied #105324Rollup merge of rust-lang#105324 - compiler-errors:gat-where-clause-b…
[-]Diagnostic points at whole path instead of GAT argument if the latter does not satisfy a trait bound[/-][+]Diagnostic points at entire path instead of path argument if the latter does not satisfy a trait bound[/+]fmease commentedon Apr 21, 2023
This also leads to some diagnostics getting deduplicated when they shouldn't. E.g. for
T::P<String, String>
wheretype P<A: Copy, B: Copy>
, we only emit a single error when it's actually two.-Zdeduplicate-diagnostics=true|false
does not have an effect on it leading me to assume the deduplication happens much earlier. Maybe when the obligations are registered since they have the same cause span.estebank commentedon Aug 25, 2023
@fmease could you provide a test for the last case you mentioned?
13 remaining items