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

Unable to deduce projection types of dyn types from supertrait bounds #777

Closed
lowr opened this issue Sep 9, 2022 · 0 comments · Fixed by #780
Closed

Unable to deduce projection types of dyn types from supertrait bounds #777

lowr opened this issue Sep 9, 2022 · 0 comments · Fixed by #780

Comments

@lowr
Copy link
Contributor

lowr commented Sep 9, 2022

Context: rust-lang/rust-analyzer#13169

It seems chalk is unable to deduce projection type of trait object types when it's not specified in dyn notation but the trait has supertrait with its projection type specified.

I expect the following tests to succeed but all three fail. This is because according to the rules described in #203, chalk yields AliasEq(<dyn Trait as Base>::Output = usize) as a subgoal but there's no "fact" clause for that to prove it. Shouldn't the AliasEq clause be also produced as a fact under these circumstances, or should we explicitly pass the AliasEq clause?

test! {
    program {
        trait Base { type Output; }
        trait Trait where Self: Base<Output = usize> {}
    }

    goal {
        forall<'s> {
            dyn Trait + 's: Trait
        }
    } yields[SolverChoice::recursive_default()] {
        expect![[r#"Unique"#]] // fails: "No possible solution"
    }

    goal {
        forall<'s> {
            dyn Trait + 's: Base<Output = usize>
        }
    } yields[SolverChoice::recursive_default()] {
        expect![[r#"Unique"#]] // fails: "No possible solution"
    }

    goal {
        forall<'s> {
            exists<T> {
                dyn Trait + 's: Base<Output = T>
            }
        }
    } yields[SolverChoice::recursive_default()] {
        // fails: "Unique; substitution [?0 := (Base::Output)<dyn for<type> [for<> Implemented(^1.0: Trait)] + '!1_0>]"
        expect![[r#"Unique; substitution [?0 := Uint(Usize)]"#]]
    }
}
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

Successfully merging a pull request may close this issue.

1 participant