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

recursive call results in unconstrained opaque type args #145

Open
lcnr opened this issue Jan 21, 2025 · 0 comments
Open

recursive call results in unconstrained opaque type args #145

lcnr opened this issue Jan 21, 2025 · 0 comments

Comments

@lcnr
Copy link
Contributor

lcnr commented Jan 21, 2025

affected test

  • tests/ui/impl-trait/recursive-bound-eval.rs
pub trait Parser<E> {
    fn parse(&self) -> E;
}

impl<E, T: Fn() -> E> Parser<E> for T {
    fn parse(&self) -> E {
        self()
    }
}

pub fn recursive_fn<E>() -> impl Parser<E> {
    move || recursive_fn().parse()
}

fn main() {}

Even when allowing the method call, we end up with following opaque type definitions and ambiguous goal

  • opaque<?recursive_call> = ?infer
  • opaque<E> = closure<fn() -> E>
  • ?infer: Parser<E> (from the .parse() call)

We could (and maybe should) apply, the defining use opaque<E> = closure<fn() -> E> to opaque<?recursive_call>, equating ?infer with closure<fn() -> ?recursive_call>, at which point this will compile after proving closure<fn() -> ?recursive_call>: Parser<E>.

@lcnr lcnr changed the title recursive call results in unconstrained opaque type args + hidden type recursive call results in unconstrained opaque type args and ambiguity Jan 21, 2025
@lcnr lcnr changed the title recursive call results in unconstrained opaque type args and ambiguity recursive call results in unconstrained opaque type args Jan 21, 2025
@lcnr lcnr moved this to potentially irrelevant in -Znext-solver=globally Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant