-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-imprecise-spansDiagnostics: spans don't point to exactly the erroneous codeDiagnostics: spans don't point to exactly the erroneous codeT-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
struct Foo;
trait Bar: TryFrom<(), Error = i32> {}
impl Bar for Foo {}
impl TryFrom<()> for Foo {
type Error = ();
fn try_from(_: ()) -> Result<Self, Self::Error> {
todo!()
}
}
Current output:
error[E0271]: type mismatch resolving `<Foo as TryFrom<()>>::Error == i32`
--> src/lib.rs:4:14
|
4 | impl Bar for Foo {}
| ^^^ expected `i32`, found `()`
|
note: required by a bound in `Bar`
--> src/lib.rs:2:24
|
2 | trait Bar: TryFrom<(), Error = i32> {}
| ^^^^^^^^^^^ required by this bound in `Bar`
Desired output:
error[E0271]: type mismatch resolving `<Foo as TryFrom<()>>::Error == i32`
--> src/lib.rs:4:14
|
6 | type Error = ();
| ^^ expected `i32`, found `()`
|
note: required by a bound in `Bar`
--> src/lib.rs:2:24
|
2 | trait Bar: TryFrom<(), Error = i32> {}
| ^^^^^^^^^^^ required by this bound in `Bar`
note: required for this impl
--> src/lib.rs:4:14
|
4 | impl Bar for Foo {}
| ^^^^^^^^^^^^^^^^
|
Similar:
struct Foo;
trait Bar: TryFrom<(), Error = i32> {}
impl Bar for Foo {}
error[E0271]: type mismatch resolving `<Foo as TryFrom<()>>::Error == i32`
--> src/lib.rs:4:14
|
4 | impl Bar for Foo {}
| ^^^ expected `i32`, found `Infallible`
|
note: required by a bound in `Bar`
--> src/lib.rs:2:24
|
2 | trait Bar: TryFrom<(), Error = i32> {}
| ^^^^^^^^^^^ required by this bound in `Bar`
error[E0277]: the trait bound `Foo: TryFrom<()>` is not satisfied
--> src/lib.rs:4:14
|
4 | impl Bar for Foo {}
| ^^^ the trait `From<()>` is not implemented for `Foo`
|
= note: required for `()` to implement `Into<Foo>`
= note: required for `Foo` to implement `TryFrom<()>`
note: required by a bound in `Bar`
--> src/lib.rs:2:12
|
2 | trait Bar: TryFrom<(), Error = i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Bar`
E0271 should probably be dropped in favor of E0277 here.
@rustbot label +A-diagnostics +A-associated-items +T-compiler +D-imprecise-spans
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-imprecise-spansDiagnostics: spans don't point to exactly the erroneous codeDiagnostics: spans don't point to exactly the erroneous codeT-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.