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 the rule introduced by #176 and accord doc with rustc-guide #184

Merged
merged 1 commit into from
Dec 17, 2018

Conversation

scalexm
Copy link
Member

@scalexm scalexm commented Oct 17, 2018

The rule introduced in #176 was too restrictive, as can be seen with this example:

trait Bar { }

trait Baz { }
// Implemented(Self: Baz) :- FromEnv(Self: Baz).

trait Foo {
    type Item<T>: Baz where T: Bar;
}

// (*) FromEnv(<Self as Foo>::Item<T>: Baz) :- FromEnv(Self: Foo), FromEnv(T: Bar).

struct AlwaysBar<T> { }
impl<T> Bar for AlwaysBar<T> { }

fn baz<X: Baz>() { }

fn foo<X: Foo, T>() // where AlwaysBar<T>: Bar
{
    // We must prove: `Implemented(<X as Foo>::Item<AlwaysBar<T>>: Baz)`.
    // The only way to prove it is to use the rule (*).
    // This requires `FromEnv(Always<T>: Bar)`, which we don't have in our env.
    baz::<X::Item<AlwaysBar<T>>>()
}

So we change it to be:

FromEnv(<Self as Foo>::Item<T>: Baz) :- FromEnv(Self: Foo), Implemented(T: Bar).

(I also accorded the doc with rust-lang/rustc-dev-guide#210)

@nikomatsakis nikomatsakis self-assigned this Dec 17, 2018
@nikomatsakis nikomatsakis merged commit cd35595 into rust-lang:master Dec 17, 2018
@scalexm scalexm deleted the fix-176-and-doc branch January 8, 2019 19:28
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