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

Change order of implicit type parameters #126

Open
tmandry opened this issue May 14, 2018 · 0 comments
Open

Change order of implicit type parameters #126

tmandry opened this issue May 14, 2018 · 0 comments
Labels
design Needs design work

Comments

@tmandry
Copy link
Member

tmandry commented May 14, 2018

Implicit type parameters (like Self and others from the env) are put into a lowered item after the explicit type parameters, which is surprising.

For example, the following test fails:

program {
    trait Combine { type Item<T>; }
    struct u32 { }
    struct i32 { }
    struct Either<T, U> { }
    impl Combine for u32 { type Item<U> = Either<u32, U>; }
    impl Combine for i32 { type Item<U> = Either<i32, U>; }
}

goal {
    exists<T, U> {
        T: Combine<Item<U> = Either<u32, i32>>
    }
} yields {
    "Unique; substitution [?0 := u32, ?1 := i32]"
}

Instead of the expected result, we get [?0 := i32, ?1 := u32], which is technically correct because our GAT parameter U is mapped to ?0 and T is mapped to ?1. But there's no way to see this from the output of chalk.

See for example: https://github.com/rust-lang-nursery/chalk/blob/94a1941a021842a5fcb35cd043145c8faae59f08/src/ir/lowering.rs#L183-L185

This will probably have to be changed in a bunch of places.

@tmandry tmandry changed the title Change order of implied type parameters Change order of implicit type parameters May 14, 2018
@jackh726 jackh726 added the design Needs design work label Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Needs design work
Projects
None yet
Development

No branches or pull requests

2 participants