Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type mismatch resolving <Thing as FromStr>::Err == <Thing as FromStr>::Err, with impl trait #41407

ben0x539 opened this issue Apr 19, 2017 · 0 comments


Copy link

@ben0x539 ben0x539 commented Apr 19, 2017

Got this diagnostic trying to avoid having to look up what error type hyper's Uri std::str::FromStr impl returns by using <Uri as FromStr>::Err as the error type of Future and then returning it abstractly: fn foo() -> impl Future<Item=Uri, Error=<Uri as FromStr>::Err>.

Kinda sounds like #34257, but the diagnostic is more confusing and it seems to depend on impl trait.

rustc 1.18.0-nightly (9f2abad 2017-04-18)

A reduced version with no external types (playground):


struct Thing;
struct ThingError;

trait FakeFromStr {
    type Err;

fn fake_parse<T: FakeFromStr>() -> Result<T, T::Err> { panic!() } 

impl FakeFromStr for Thing {
    type Err = ThingError;

trait FakeFuture {
    type Item;
    type Error;

struct FakeFutureResult<A, B>(Result<A, B>);
impl<A, B> FakeFuture for FakeFutureResult<A, B> {
    type Item = A;
    type Error = B;

fn foo() -> impl FakeFuture<Item=Thing, Error=<Thing as FakeFromStr>::Err> {

fn main() {
    let _ = foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants