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

Open
ben0x539 opened this Issue Apr 19, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@ben0x539
Copy link
Contributor

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):

#![feature(conservative_impl_trait)]

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> {
    FakeFutureResult(fake_parse())
}

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