Skip to content

generalization ambiguity 2 - even yoke-ier #110

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

Closed
lcnr opened this issue May 7, 2024 · 4 comments
Closed

generalization ambiguity 2 - even yoke-ier #110

lcnr opened this issue May 7, 2024 · 4 comments

Comments

@lcnr
Copy link
Contributor

lcnr commented May 7, 2024

#![allow(unused)]
trait Yokeable<'a> {
    type Output;
}
trait Id {
    type Refl;
}

fn into_deserialized<M: Id>() -> M
where
    M::Refl: for<'a> Yokeable<'a>,
{
    try_map_project::<M, _>(|_| todo!())
}

fn try_map_project<M: Id, F>(_f: F) -> M
where
    M::Refl: for<'a> Yokeable<'a>,
    F: for<'a> FnOnce(&'a ()) -> <<M as Id>::Refl as Yokeable<'a>>::Output,
{
    todo!()
}

fn main() {}
@lcnr
Copy link
Contributor Author

lcnr commented May 7, 2024

likely caused by closure signature inference

@lcnr
Copy link
Contributor Author

lcnr commented May 7, 2024

#![allow(unused)]
trait HigherRanked {
    type Output<'a>;
}
trait Id {
    type Refl: HigherRanked;
}

fn foo<T: Id>() -> for<'a> fn(<<T as Id>::Refl as HigherRanked>::Output<'a>) {
    todo!()
}

fn bar<T: Id>() {
    // generalize here:
    let x = foo::<T>();
}

fn main() {}

@lcnr
Copy link
Contributor Author

lcnr commented May 7, 2024

not caused by closure signature inference: if the outer alias refernces a bound var, the generalizer recurses into it, but then if the nested alias does not refer to bound vars, it gets replaced with an inference variable:

https://github.com/rust-lang/rust/blob/5ae5d135372c4b576edc73c191d2dc86b1d16b5c/compiler/rustc_infer/src/infer/relate/generalize.rs#L353-L358

We generalize for<'a> fn(<<T as Id>::Refl as HigherRanked>::Output<'a>) to for<'a> fn(<?new as HigherRanked>::Output<'a>)

@lcnr
Copy link
Contributor Author

lcnr commented May 13, 2024

fixed by rust-lang/rust#124827

@lcnr lcnr closed this as completed May 13, 2024
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