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

chalk lowering rule: ProjectionEq-Normalize #52153

Merged
merged 1 commit into from Nov 14, 2018

Conversation

Projects
None yet
8 participants
@csmoe
Member

csmoe commented Jul 8, 2018

cc #49177
r? @scalexm

@rust-highfive

This comment was marked as outdated.

Collaborator

rust-highfive commented Jul 9, 2018

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:start:test_ui
Check compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:42:52] 
[00:42:52] running 1554 tests
[00:42:58] .............................................................................F.....................i
[00:43:08] ....................................................................................................
[00:43:12] ....................................................................................................
[00:43:16] ....................................................................................................
[00:43:19] ....................................................................................................
---
[00:43:47] ..................................i.................................................................
[00:43:52] .......................i............................................................................
[00:43:58] ....................................................................................................
[00:44:04] ....................................................................................................
l},{"message":"Implemented(Self: Foo) :- FromEnv(Self: Foo).","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: program clause dump\n  --> /checkout/src/test/ui/chalkify/lower_trait_associate_ty_def.rs:13:1\n   |\nLL | #[rustc_dump_program_clauses] //~ ERROR program clause dump\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: FromEnv(<Self as Foo>::U: std::marker::Sized) :- FromEnv(Self: Foo).\n   = note: Implemented(Self: Foo) :- FromEnv(Self: Foo).\n\n"}
[00:44:14] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:44:14] ------------------------------------------
[00:44:14] 
[00:44:14] thread '[ui] ui/chalkify/lower_trait_associate_ty_def.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3140:9
[00:44:14] note: Run with `RUST_BACKTRACE=1` for a backtrace.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors

This comment was marked as resolved.

Contributor

bors commented Jul 9, 2018

☔️ The latest upstream changes (presumably #50250) made this pull request unmergeable. Please resolve the merge conflicts.

@TimNN

This comment was marked as outdated.

Contributor

TimNN commented Jul 17, 2018

Ping from triage @csmoe / @scalexm: This PR is waiting to be reviewed and has a merge conflict / CI failure.

let trait_ref = tcx.impl_trait_ref(trait_id).unwrap();
// `U`
let ty = tcx.type_of(item_id);

This comment has been minimized.

@scalexm

scalexm Jul 20, 2018

Member

I don’t think this will work, what we want to do is to introduce a new type parameter U. Not sure how to do that (probably through tcx.mk_ty_param), I’ll try and get back to you for more guidance.

This comment has been minimized.

@csmoe

csmoe Jul 20, 2018

Member

thank you.

This comment has been minimized.

@scalexm

scalexm Jul 27, 2018

Member

Ok so as you can see in the description of the rule, we want the output to be something like:

ProjectionEq(<Self as Trait>::Item = U) :- Normalize(<Self as Trait>::Item = U)

where U is a new type variable. This could be done naively by having:

// add a type param at depth `0`
let ty = tcx.mk_ty_param(0, Symbol::intern(“U”).as_interned_str());

however as you can see, rustc refers to a type param with a depth index and an explicit name (here “U”), instead of referring to all parameters by using indices only. Hence if the name U is already taken, as in:

trait Foo<U> {
    #[rustc_dump_program_clauses]
    type Item;
}

then the output clause will be wrong as it will use the same parameter U for two unrelated things.

A possible fix would be to choose U whenever this name is not already in use, and in case it is used just choose a random name which is not already in use. Another possible fix would be two Binder layers instead of only one, as I think type parameters can have the same name if they are not at the same depth. I’ll confer with niko.

This comment has been minimized.

@nikomatsakis

nikomatsakis Aug 8, 2018

Contributor

Hmm so the problem here is that rustc doesn't really support this yet

This comment has been minimized.

@nikomatsakis

nikomatsakis Aug 8, 2018

Contributor

I wonder if we can leave this as a kind of FIXME for now

Show resolved Hide resolved src/librustc_traits/lowering.rs Outdated
Show resolved Hide resolved src/librustc_traits/lowering.rs Outdated
Show resolved Hide resolved src/librustc_traits/lowering.rs Outdated
Show resolved Hide resolved src/librustc_traits/lowering.rs Outdated
let trait_ref = tcx.impl_trait_ref(trait_id).unwrap();
// `U`
let ty = tcx.type_of(item_id);

This comment has been minimized.

@scalexm

scalexm Jul 27, 2018

Member

Ok so as you can see in the description of the rule, we want the output to be something like:

ProjectionEq(<Self as Trait>::Item = U) :- Normalize(<Self as Trait>::Item = U)

where U is a new type variable. This could be done naively by having:

// add a type param at depth `0`
let ty = tcx.mk_ty_param(0, Symbol::intern(“U”).as_interned_str());

however as you can see, rustc refers to a type param with a depth index and an explicit name (here “U”), instead of referring to all parameters by using indices only. Hence if the name U is already taken, as in:

trait Foo<U> {
    #[rustc_dump_program_clauses]
    type Item;
}

then the output clause will be wrong as it will use the same parameter U for two unrelated things.

A possible fix would be to choose U whenever this name is not already in use, and in case it is used just choose a random name which is not already in use. Another possible fix would be two Binder layers instead of only one, as I think type parameters can have the same name if they are not at the same depth. I’ll confer with niko.

@csmoe

This comment has been minimized.

Member

csmoe commented Jul 27, 2018

@scalexm thank you, Your instructions will be addressed soon.

@TimNN

This comment was marked as outdated.

Contributor

TimNN commented Aug 7, 2018

Ping from triage, @csmoe! Could you give us a quick update on your plans for this PR?

@csmoe

This comment was marked as outdated.

Member

csmoe commented Aug 9, 2018

@TimNN I was waiting niko's feed back on the review #52153 (comment), more commits soon since niko replied just now.

@csmoe csmoe force-pushed the csmoe:projeq_normal branch from da979d0 to 139cab9 Aug 13, 2018

@scalexm

This comment has been minimized.

Member

scalexm commented Aug 17, 2018

@csmoe I think that’s good now! cc @nikomatsakis, what do you think of the FIXME?

@pietroalbini

This comment has been minimized.

Member

pietroalbini commented Aug 27, 2018

Ping from triage @nikomatsakis! This PR needs your review.

@TimNN

This comment has been minimized.

Contributor

TimNN commented Sep 4, 2018

Ping from triage @nikomatsakis / @rust-lang/compiler: This PR requires your review.

@TimNN

This comment has been minimized.

Contributor

TimNN commented Sep 11, 2018

Ping from triage @rust-lang/compiler / @nikomatsakis: This PR requires your review.

@scalexm

This comment has been minimized.

Member

scalexm commented Oct 2, 2018

I propose that we wait for rustc to handle quantification over types, once this is done it should be almost trivial to finish this PR.

@bors

This comment has been minimized.

Contributor

bors commented Oct 11, 2018

☔️ The latest upstream changes (presumably #54969) made this pull request unmergeable. Please resolve the merge conflicts.

@scalexm scalexm force-pushed the csmoe:projeq_normal branch from 3723239 to e853d6c Nov 13, 2018

@scalexm

This comment has been minimized.

Member

scalexm commented Nov 13, 2018

@bors r+
Unblocked by #55330

@bors

This comment has been minimized.

Contributor

bors commented Nov 13, 2018

📌 Commit e853d6c has been approved by scalexm

@bors

This comment has been minimized.

Contributor

bors commented Nov 14, 2018

⌛️ Testing commit e853d6c with merge 126a0e2...

bors added a commit that referenced this pull request Nov 14, 2018

Auto merge of #52153 - csmoe:projeq_normal, r=scalexm
chalk lowering rule: ProjectionEq-Normalize

cc #49177
r? @scalexm
@bors

This comment has been minimized.

Contributor

bors commented Nov 14, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: scalexm
Pushing 126a0e2 to master...

@bors bors merged commit e853d6c into rust-lang:master Nov 14, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Nov 14, 2018

📣 Toolstate changed by #52153!

Tested on commit 126a0e2.
Direct link to PR: #52153

🎉 rls on windows: test-fail → test-pass (cc @nrc @Xanewok, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Nov 14, 2018

📣 Toolstate changed by rust-lang/rust#52153!
Tested on commit rust-lang/rust@126a0e2.
Direct link to PR: <rust-lang/rust#52153>

🎉 rls on windows: test-fail → test-pass (cc @nrc @Xanewok, @rust-lang/infra).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment