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

Fix UnselectedProjectionTy parameters #84

Merged
merged 2 commits into from
Mar 7, 2018

Conversation

scalexm
Copy link
Member

@scalexm scalexm commented Feb 8, 2018

There were two problems with how UnselectedProjectionTy parameters where handled:

Firstly, they were in the wrong order with respect to those of ProjectionTy, i.e. the bound parameters of the associated type value should come first, then the Self type should come. For example, given:

trait Foo {
    type Item<'a>;
}

impl<T> Foo for T {
    type Item<'a> = Ref<'a, T>;
}

we would issue clauses like UnselectedNormalize('a::Item<T> -> Ref<'a, T>) :- ... instead of UnselectedNormalize(T::Item<'a> -> Ref<'a, T>) :- ....

Secondly, if the trait ref had any more parameters (in addition of the Self parameter), we would add those extra parameters to the UnselectedNormalize clause in ir::AssociatedTyValue::to_program_clauses. For example, given:

trait Foo<U> {
    type Item;
}

impl<T, U> Foo<U> for T {
    type Item = T;
}

we would issue clauses like UnselectedNormalize(T::Item<U> -> T) :- ... instead of UnselectedNormalize(T::Item -> T) :- ....

This would eventually give zipping things of mixed type panics. Fixes #70.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Do you have a test case for #70?

let mut args = vec![Parameter::Ty(ty)];
args.extend(a);
let mut args = a;
args.push(Parameter::Ty(ty));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, self comes first because it is of the trait.

@scalexm
Copy link
Member Author

scalexm commented Feb 22, 2018

Added two tests that would fail with current master branch (@nikomatsakis).

@nikomatsakis nikomatsakis merged commit 82a8472 into rust-lang:master Mar 7, 2018
@scalexm scalexm deleted the issue-70 branch November 29, 2018 18:37
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 this pull request may close these issues.

2 participants