-
Notifications
You must be signed in to change notification settings - Fork 13k
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
rework how we handle outlives relationships #54453
rework how we handle outlives relationships #54453
Conversation
2136fd4
to
6796c4d
Compare
The job Click to expand the log.
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 |
Aww tidy failure ... |
☔ The latest upstream changes (presumably #54262) made this pull request unmergeable. Please resolve the merge conflicts. |
src/librustc/infer/mod.rs
Outdated
/// A flag that is given when running region resolution: if true, it | ||
/// indicates that we should not report the region errors to the user | ||
/// if NLL is enabled, since NLL will also detect them (and do a | ||
/// better job of it). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Should this comment include the special role of
borrowck=migrate
? -
Instead of checking for the borrowck=mode after seeing
UnlessNll(true)
, maybe we should revise howUnlessNll
itself is initialized based on inspecting thatBorrowckMode
?
- Its up to you; I just know that I initially found the name
UnlessNll
confusing, given that we will emit the errors under the migration mode... But of course that was inherited from the previous code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like if we do the checking before initializing UnlessNll
, I would just call it Ignore
or something like that, since at that point it is encoding whether to ignore the error and nothing else, right?
(Right now it's saying "is this the sort of error we should ignore if NLL is enabled" — maybe I can improve the comment this way?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not inclined to move the logic earlier because it's created many places -- well, I guess I can just have a constructor like RegionErrors::suppress_if_nll()
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, did that, and it seems nice. will push a commit.
/// user has `<T as Trait<'a>>::Item: 'b` in the environment, then | ||
/// the clause from the environment only applies if `'0 = 'a`, | ||
/// which we don't know yet. But we would still include `'b` in | ||
/// this list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going through the PR commit-by-commit, so this question may get answered later on, but I don't want to forget to ask it: What is the intended use of this check, where it sounds like it is incomplete on two axes...?
My current hypothesis is that this check is used to provide diagnostics in scenarios where we are comfortable giving feedback suggesting the user might need to satisfy some constraint, when the reality is that they might be able to sidestep the constraint... That probably didn't make sense. let me try again
Here's a different version of my question: You have given a concrete example where the list returned by this function would include 'b
, even though that bound may not apply, since it depends on the whether it is true that '0 = 'a
. So: Do you have an example of a diagnostic where as a user one can see the effect of 'b
being on this list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question might be answered by cebf83502fd7c57dd2a7d1481b00d93ec03bab0e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Though commit cebf83502fd7c57dd2a7d1481b00d93ec03bab0e only has tests being updated that are observing internal region representations... I think some of tests still show side-effects that end-users can observe without using -Z
flags or internal features, but I hope that by the time I get to the end of the commit series, there will be a concrete test that demonstrates the effect without -Z
flags or internal features.)
@@ -0,0 +1,26 @@ | |||
#![feature(nll)] | |||
|
|||
// Test that we are NOT able to establish that `<T as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there no projection-where-clause-none.stderr
in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(it seems like a bunch of .stderr
files have been left out of this PR?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, curious, I have no such files locally...? I'll fix, anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I misunderstand how ui
tests work...
I had assumed that any test without // run-pass
or // compile-pass
was implicitly interpreted as a // compile-fail
test; and all such tests should have stderr output. So that would mean they need .stderr
files, right?
Does compiletest
... not complain if the .stderr
files are entirely missing for compile-fail tests? It certainly seemed to complain about them missing for // run-pass
tests...
Okay this all seems fine. r=me once you've placated travis, which presumably will require tidying and adding some missing |
I'm pulling the answer to this out because I will rebase and your comments will likely be lost. The idea of the "approximate" check is that we find out: "Are there any where clauses that might potentially be useful once region inference is done, presuming we inferred the various region values to the right values?" It's not really meant to be conservative in "two dimensions". That is, I might be able to fix those cases where we are "overly" conservative though via a more thorough erasure. I think erasing regions today preserves the lifetime bounds, but we would ideally look for an "equality" check that just completely ignores region equality (even around binders). I was working towards that but never finished it. |
6796c4d
to
1598f77
Compare
The job Click to expand the log.
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 |
303f8e2
to
a7d9b84
Compare
The job Click to expand the log.
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 |
@bors r=pnkfelix |
📌 Commit 781a0bd825684378181f4dedf8864e600723e227 has been approved by |
filed #54572 as a follow-up issue |
☔ The latest upstream changes (presumably #53542) made this pull request unmergeable. Please resolve the merge conflicts. |
This lets us remove `for_each_region` and makes things simpler.
It's a bit cleaner to just have `AnyBound` and `AllBound`, after all.
Hopefully this will help clarify the behavior in the various borrowck modes
Pacify the mercilous tidy.
781a0bd
to
f23fd4b
Compare
@bors r=pnkfelix |
📌 Commit f23fd4b has been approved by |
…=pnkfelix rework how we handle outlives relationships When we encounter an outlives relationship involving a projection, we use to over-constrain in some cases with region constraints. We also used to evaluate whether the where-clauses in the environment might apply **before** running inference. We now avoid doing both of those things: - If there are where-clauses in the environment that might be useful, we add no constraints. - After inference is done, we check if we wound up inferring values compatible with the where-clause, and make use of them if so. I realize now that this PR includes some meandering commits and refactorings from when I expected to go in a different direction. If desired, I could try to remove some of those. Fixes #53121 Fixes #53789 r? @pnkfelix
☀️ Test successful - status-appveyor, status-travis |
When we encounter an outlives relationship involving a projection, we use to over-constrain in some cases with region constraints. We also used to evaluate whether the where-clauses in the environment might apply before running inference.
We now avoid doing both of those things:
I realize now that this PR includes some meandering commits and refactorings from when I expected to go in a different direction. If desired, I could try to remove some of those.
Fixes #53121
Fixes #53789
r? @pnkfelix