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 1 commit into from Dec 17, 2018


Copy link

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.

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-guide#210)

@nikomatsakis nikomatsakis self-assigned this Dec 17, 2018
@nikomatsakis nikomatsakis merged commit cd35595 into rust-lang:master Dec 17, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
@scalexm scalexm deleted the scalexm:fix-176-and-doc branch Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.