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

handle outlives predicates in trait evaluation #54624

Merged
merged 3 commits into from
Oct 4, 2018

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Sep 27, 2018

This handles higher-ranked outlives predicates in trait evaluation the same way they are handled in projection.

Fixes #54302. I think this is a more correct fix than #54401 because it fixes the root case in evaluation instead of making evaluation used in less cases. However, we might want to go to a direction closer to @nikomatsakis's solution with Chalk.

r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 27, 2018
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.

I agree this is good. I'm happy to land this in place of my PR. Left a few nits/thoughts, though.

Also, do you still think we need to keep that !data.has_late_bound_regions() check, though? If so, why?

if r_a == r_b {
// for<'a> 'a: 'a. OK
Ok(EvaluatedToOk)
} else if r_a.is_late_bound() || r_b.is_late_bound() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Annoyingly, the current region solver has one extra case to consider: the case where r_a is 'static. In that case, know it outlives any r_b. But we support this case inconsistently owing to the leak-check. Not sure how relevant that is here.

Copy link
Contributor

Choose a reason for hiding this comment

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

In particular, even within the leak check, we don't generate a constraint like 'a <= 'static, and hence the leak-check doesn't fail:

(_, &ReStatic) => {
// all regions are subregions of static, so we can ignore this
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The caching code that is going wrong — however — only cares about predicate_must_hold, so it's ok to falsely fail from time to time. Still, we might want this to be is_late_bound() && is_late_bound()?

You mentioned coherence, though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is trait inference, so I don't think r_a can ever end up being literally 'static (as opposed to being some inference variable that happens to be equatable to 'static).

Copy link
Contributor Author

@arielb1 arielb1 Sep 28, 2018

Choose a reason for hiding this comment

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

Actually, I think the only way something like this might happen if someone writes a literal where 'static: 'a bound in their trait. In this case, evaluation would return an error, but fulfillment would be ok. I'm not sure this inconsistency

Currently I did the EvaluatedToAmbig thing in intercrate mode, so this won't affect coherence.

@arielb1
Copy link
Contributor Author

arielb1 commented Sep 28, 2018

Eventually I decided on adding support for the literal-ReStatic case, to not regress on handling where 'static: 'a where-clauses.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 2, 2018

📌 Commit 1069c0e has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2018
@bors
Copy link
Contributor

bors commented Oct 3, 2018

⌛ Testing commit 1069c0e with merge 33a3327eb9e324cb13bca0eb2ffd9e23262c82fe...

@bors
Copy link
Contributor

bors commented Oct 3, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 3, 2018
@rust-highfive
Copy link
Collaborator

The job dist-x86_64-linux-alt 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:end:02f3f53c:start=1538548498697509639,finish=1538548498705474560,duration=7964921
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:2825a210
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:20ecfef3
travis_time:start:20ecfef3
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:010e9740
$ dmesg | grep -i kill

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)

@kennytm
Copy link
Member

kennytm commented Oct 3, 2018

@bors retry travis-ci/travis-ci#9696

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 3, 2018
…tsakis

handle outlives predicates in trait evaluation

This handles higher-ranked outlives predicates in trait evaluation the same way they are handled in projection.

Fixes rust-lang#54302. I think this is a more correct fix than rust-lang#54401 because it fixes the root case in evaluation instead of making evaluation used in less cases. However, we might want to go to a direction closer to @nikomatsakis's solution with Chalk.

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Oct 4, 2018

⌛ Testing commit 1069c0e with merge c67ea54...

bors added a commit that referenced this pull request Oct 4, 2018
handle outlives predicates in trait evaluation

This handles higher-ranked outlives predicates in trait evaluation the same way they are handled in projection.

Fixes #54302. I think this is a more correct fix than #54401 because it fixes the root case in evaluation instead of making evaluation used in less cases. However, we might want to go to a direction closer to @nikomatsakis's solution with Chalk.

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Oct 4, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing c67ea54 to master...

@bors bors merged commit 1069c0e into rust-lang:master Oct 4, 2018
@nnethercote
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trait with HRTB blanket impl is implemented when it shouldn't be
6 participants