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

Closed
ben0x539 opened this issue Apr 19, 2017 · 1 comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ben0x539
Copy link
Contributor

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();
}
@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. labels Jun 21, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@jyn514
Copy link
Member

jyn514 commented Jul 7, 2021

Triage: this now compiles.

@jyn514 jyn514 closed this as completed Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants