Open
Description
When a type does not match a generic parameter (I'm not sure if it's treated differently if it's because a generic constraint failed or because a previous usage dictated a particular variant of that generic), the resulting error message is not helpful because it seems to indicate that everything is OK.
As an example:
error[E0308]: mismatched types
--> src/main.rs:80:23
|
80 | return Ok(response);
| ^^^^^^^^ expected type parameter, found struct `std::io::Cursor`
|
= note: expected type `tiny_http::Response<R>`
found type `tiny_http::Response<std::io::Cursor<std::vec::Vec<u8>>>`
= help: here are some functions which might fulfill your needs:
- .with_data(...)
- .with_header(...)
- .with_status_code(...)
the method in question was declared as
fn send_email<R>(req: &mut Request) -> Result<Response<R>, String>
where R: std::io::Read
I believe the compiler message should at least indicate the constraints on R
, because as it currently reads, tiny_http::Response<std::io::Cursor<std::vec::Vec<u8>>>
is a valid form of tiny_http::Response<R>
for R=std::io::Cursor<std::vec::Vec<u8>>
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: Suggestions generated by the compiler applied by `cargo fix`Area: Type systemCategory: An issue proposing an enhancement or a PR with one.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.Working group: Diagnostics