{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/40186","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/40186/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/40186/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/40186/events","html_url":"https://github.com/rust-lang/rust/issues/40186","id":211183562,"number":40186,"title":"Improve output of E0271","user":{"login":"seanmonstar","id":51479,"avatar_url":"https://avatars2.githubusercontent.com/u/51479?v=3","gravatar_id":"","url":"https://api.github.com/users/seanmonstar","html_url":"https://github.com/seanmonstar","followers_url":"https://api.github.com/users/seanmonstar/followers","following_url":"https://api.github.com/users/seanmonstar/following{/other_user}","gists_url":"https://api.github.com/users/seanmonstar/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmonstar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmonstar/subscriptions","organizations_url":"https://api.github.com/users/seanmonstar/orgs","repos_url":"https://api.github.com/users/seanmonstar/repos","events_url":"https://api.github.com/users/seanmonstar/events{/privacy}","received_events_url":"https://api.github.com/users/seanmonstar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-01T19:29:58Z","updated_at":"2017-03-01T19:29:58Z","closed_at":null,"body":"This error is encountered often with futures and tokio, where a returned future has an associated type that doesn't match the expected return type.\r\n\r\nAn example of current behavior:\r\n\r\n```\r\nerror[E0271]: type mismatch resolving `<futures::AndThen<futures::stream::Fold<futures::stream::MapErr<hyper::Body, [closure@src/consumer/pinger.rs:100:41: 107:18 uri:_, request_type:_, correlation_id:_, tx:_, event:_]>, [closure@src/consumer/pinger.rs:107:35: 110:18], futures::FutureResult<std::vec::Vec<u8>, futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>>, std::vec::Vec<u8>>, futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>, [closure@src/consumer/pinger.rs:110:29: 127:18 timer:_, status_code:_, response_status:_, uri:_, tx:_, event:_, headers:_, request_type:_, correlation_id:_]> as futures::IntoFuture>::Error == futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>`\r\n   |\r\n16 |     Box::new(\r\n   |     ^ expected futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>, found struct `io::Error`\r\n   |\r\n   = note: expected type `futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>`\r\n   = note:    found type `io::Error`\r\n   = note: required for the cast to the object type `Future<Error=futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>> + 'static`\r\n```\r\n\r\nAnd a playpen of a the current behavior (though the error is much smaller): https://is.gd/iigJ2p\r\n\r\nA message like this pushes the actionable information down several lines. It may help to instead, output something like this:\r\n\r\n```\r\nerror[E0271]: type mismatch resolving `<futures::AndThen<...>::Error`\r\n   |\r\n16 |     Box::new(\r\n   |     ^ expected futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>, found struct `io::Error`\r\n   |\r\n   = note: expected type `futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>`\r\n   = note:    found type `io::Error`\r\n   = note: required for the cast to the object type `Future<Error=futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>> + 'static`\r\n   = note: full type is `<futures::AndThen<futures::stream::Fold<futures::stream::MapErr<hyper::Body, [closure@src/consumer/pinger.rs:100:41: 107:18 uri:_, request_type:_, correlation_id:_, tx:_, event:_]>, [closure@src/consumer/pinger.rs:107:35: 110:18], futures::FutureResult<std::vec::Vec<u8>, futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>>, std::vec::Vec<u8>>, futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>, [closure@src/consumer/pinger.rs:110:29: 127:18 timer:_, status_code:_, response_status:_, uri:_, tx:_, event:_, headers:_, request_type:_, correlation_id:_]> as futures::IntoFuture>::Error == futures::sink::Send<futures::sync::mpsc::Sender<(events::http_request_event::HttpRequestEvent, std::result::Result<consumer::pinger::HttpResult, consumer::pinger::HttpResult>)>>`\r\n```\r\n\r\nAdditionally, it might be even clearer to omit some of the type parameters (leaving enough to differentiate) in the 'expected' and 'found' notes, leaving the full type for the bottom note. \r\n\r\n```\r\nerror[E0271]: type mismatch resolving `<futures::AndThen<...>::Error`\r\n   |\r\n16 |     Box::new(\r\n   |     ^ expected futures::sink::Send<...>, found struct `io::Error`\r\n   |\r\n   = note: expected type `futures::sink::Send<...>`\r\n   = note:    found type `io::Error`\r\n```\r\n\r\ncc @eddyb "}}
{"actor":{"display_login":"seanmonstar"}}