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

generalization ambiguity #108

Closed
lcnr opened this issue May 6, 2024 · 1 comment · Fixed by rust-lang/rust#124827
Closed

generalization ambiguity #108

lcnr opened this issue May 6, 2024 · 1 comment · Fixed by rust-lang/rust#124827
Labels
blocks-crater Blocks running a crater run for breakage w/ new solver

Comments

@lcnr
Copy link
Contributor

lcnr commented May 6, 2024

#![allow(unused)]

trait Trait<'a> {
    type Assoc;
}

impl<'a> Trait<'a> for () {
    type Assoc = ();
}

fn foo<T: for<'a> Trait<'a>>(x: T) -> for<'a> fn(<T as Trait<'a>>::Assoc) {
    |_| ()
}

fn unconstrained<T>() -> T {
    todo!()
}

fn main() {
    // in universe 0
    let mut x = unconstrained();

    let bump: for<'a, 'b> fn(&'a (), &'b ()) = |_, _| ();
    let _: for<'a> fn(&'a (), &'a ()) = bump;
    // in universe 1
    let mut y = Default::default();

    // ?x.0 :> for<'a> fn(<?y.1 as Trait<'a>>::Assoc) ~>
    // ?x.0 instantiated for<'a> fn(<?x'.0 as Trait<'a>>::Assoc)
    x = foo(y);
    
    // for<'a> fn(<?x'.0 as Trait<'a>>::Assoc) :> <() as Trait<'a>>::Assoc stays ambig
    let _: () = y;
    
}
@lcnr lcnr added the blocks-crater Blocks running a crater run for breakage w/ new solver label May 6, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 7, 2024
…iler-errors

generalize hr alias: avoid unconstrainable infer vars

fixes rust-lang/trait-system-refactor-initiative#108

see inline comments for more details

r? `@compiler-errors` cc `@BoxyUwU`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 7, 2024
Rollup merge of rust-lang#124827 - lcnr:generalize-incomplete, r=compiler-errors

generalize hr alias: avoid unconstrainable infer vars

fixes rust-lang/trait-system-refactor-initiative#108

see inline comments for more details

r? `@compiler-errors` cc `@BoxyUwU`
@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
blocks-crater Blocks running a crater run for breakage w/ new solver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant