-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Uplifted from #105306 (comment) & #105306 (comment).
CC @estebank
For the following erroneous code, rustc only emits a single error while ideally it should emit two errors. Presumably, this happens because the two predicate obligations for String: Copy
have the same cause span (namely of the entire path) before any fulfillment error adjustment takes place and therefore they get deduplicated early on. Details may vary.
Original reproducer (involving projections):
trait Trait {
type P<T: Copy, U: Copy>;
}
impl Trait for () {
type P<T: Copy, U: Copy> = ();
}
fn main() {
let _: <() as Trait>::P<String, String>;
}
Current output (1 error):
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/main.rs:8:29
|
8 | let _: <() as Trait>::P<String, String>;
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound in `Trait::P`
--> src/main.rs:2:15
|
2 | type P<T: Copy, U: Copy>;
| ^^^^ required by this bound in `Trait::P`
Expected output (2 errors):
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/main.rs:8:12
|
8 | let _: <() as Trait>::P<String, String>;
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound in `Trait::P`
--> src/main.rs:2:15
|
2 | type P<T: Copy, U: Copy>;
| ^^^^ required by this bound in `Trait::P`
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/main.rs:8:12
|
8 | let _: <() as Trait>::P<String, String>;
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound in `Trait::P`
--> src/main.rs:2:24
|
2 | type P<T: Copy, U: Copy>;
| ^^^^ required by this bound in `Trait::P`
Another very similar reproducer (involving ADTs) which probably takes a slightly different execution path in the compiler:
struct S<T: Copy, U: Copy>(T, U);
fn main() {
let _: S<String, String>;
}
Meta
rustc -Vv
rustc 1.74.0-nightly (668bf8c59 2023-08-27)
binary: rustc
commit-hash: 668bf8c5932933255ba278f50fdbe308f7abe60f
commit-date: 2023-08-27
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0
@rustbot label T-compiler A-diagnostics D-incorrect
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.