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

Fails to solve some existential clause #816

Open
ShoyuVanilla opened this issue Aug 15, 2024 · 2 comments
Open

Fails to solve some existential clause #816

ShoyuVanilla opened this issue Aug 15, 2024 · 2 comments

Comments

@ShoyuVanilla
Copy link
Member

#[test]
fn trait_parameter() {
    test! {
        program {
            #[non_enumerable]
            trait Trait<T> {
                type Assoc;
            }

            struct Foo {}
            struct Bar {}

            impl Trait<()> for Foo {
                type Assoc = Bar;
            }
        }

        goal {
            exists<T, U> {
                <Foo as Trait<T>>::Assoc = U
            }
        } yields {
            expect![[r#"Unique; substitution [?0 := 0<[]>, ?1 := Bar<[]>]"#]]
        }
    }
}

fails with

program {
    #[non_enumerable] trait Trait<T> { type Assoc; } struct Foo {} struct Bar
    {} impl Trait<()> for Foo { type Assoc = Bar; }
}
----------------------------------------------------------------------
goal { exists<T, U> { <Foo as Trait<T>>::Assoc = U } }
using solver: SLG { max_size: 10, expected_answers: None }
----------------------------------------------------------------------
goal { exists<T, U> { <Foo as Trait<T>>::Assoc = U } }
using solver: Recursive { overflow_depth: 100, caching_enabled: true, max_size: 30 }

comparing solvers:
        expected: SLG { max_size: 10, expected_answers: None }
        actual: Recursive { overflow_depth: 100, caching_enabled: true, max_size: 30 }

expected:
Ambiguous; no inference guidance
actual:
Ambiguous; no inference guidance
@jackh726
Copy link
Member

You could have a downstream crate with struct Local; impl Trait<Local> for Foo { .. }.

Then, () and Local don't unify and its ambiguous.

This should give guidance, though.

@ShoyuVanilla
Copy link
Member Author

Oh, I see. Thanks for the answer. I'll try investigating in that way

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

2 participants