Uh oh!
There was an error while loading. Please reload this page.
Make coherence more tolerant of error types. - #30676
Conversation
rust-highfive
commented
Jan 2, 2016
r? @Aatch (rust_highfive has picked a reviewer for you, use r? to override) |
nikomatsakis
commented
Jan 2, 2016
@arielb1 in case it wasn't clear, this is what I meant -- thoughts on which approach is overall better? Incidentally, I do agree that refactoring projection to be explicitly fallible is probably a good idea (versus the current "return an obligation that is known to result in an error"). |
arielb1
commented
Jan 3, 2016
I feel that the handling of |
nikomatsakis
commented
Jan 4, 2016
Do you mean specifically the way the projection code injects a TyError and an "obligation that should yield an error"? If so, I agree -- TyError ought to only be used when an error has been reported, and it violates that rule. |
nikomatsakis
commented
Jan 4, 2016
Added two new tests for other scenarios. I am torn here, in that I do feel this approach is how |
bors
commented
Jan 7, 2016
☔ The latest upstream changes (presumably #30317) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
commented
Jan 7, 2016
@arielb1 so take a look at that last commit. I changed the |
nikomatsakis
commented
Jan 7, 2016
Hmm, that branch seems to fail compile-fail. No time to look at why that is just ntke though. |
nikomatsakis
commented
Jan 7, 2016
Just NOW |
arielb1
commented
Jan 7, 2016
The code is an rpass in my branch (and my simplified example). I think that improving |
nikomatsakis
commented
Jan 7, 2016
Well, I see, the problems are just (as might be expected) that we get some derived errors we ought not to be seeing (because we are no longer returning |
arielb1
commented
Jan 7, 2016
If this is so simple, I'll r+ if you fix the errors. I also prefer that you use this simplified testcase: pubtraitFoo{typeOutput:'static;}pubtraitBar<P>{}pubtraitBaz<P>{}impl<T:'static,W:Foo<Output=T>>Baz<*mutT>forW{}impl<P,T:Baz<P>>Bar<P>forT{}impl<T>Bar<*mutT>for[T;1]{}fnmain(){} |
arielb1
commented
Jan 8, 2016
The reordering fix also seems to resolve the ICE, but I like yours better. |
nikomatsakis
commented
Jan 8, 2016
@arielb1 So i've been thinking about this all morning and digging through logs. I think I have now come to the conclusion that indeed the only non-scary fix is to stop having First off, the general strategy with Now, the code in However, what coherence is interested in is actually a different predicate. Using RFC 1144 syntax, coherence is really evaluating There are in fact other situations where this crops up. The current technique for handling them is checking the So now, your original patch made me uneasy because At some point I was considering that we could just make Scary thought the first. PR #30533 introduces some logic like the following: if we see an error evaluating obligation X occurring in tree Y, we can ignore all further pending obligations in tree Y, because we know that tree Y will never succeed. However, that would be incorrect in the face of the Scary thought the second. The whole logic relies on the idea that we will report an error when we later encounter the obligation that failed to resolve. But in this case (and I think we saw this before), the projection itself is part of that trait reference. That is, we have a constraint like So now the question becomes: can we suppress the derived error reporting in some useful way? Initially I had the thought that we could resolve to the projection but record the projection in the Therefore, right now, I am leaning towards not suppressing the derived errors. They are sort of comprehensible anyhow. In the future, I would like to move towards lazy normalization (enabled by #30533 in any case), which would give us a chance to overhaul the normalization and |
nikomatsakis
commented
Jan 8, 2016
@arielb1 I feel like scary thought the second is something we discovered already and I just forgot about. Is that true? Do you remember? |
nikomatsakis
commented
Jan 8, 2016
Oh, well, obviously that is true, given that the comment that I myself removed talks about it. Well, yeah, it's not good. |
nikomatsakis
commented
Jan 8, 2016
Hmm, I just got to thinking. In the cyclic case, is it possible that unifying will still leave us in an exposed position? Surely it's better to unify with |
nikomatsakis
commented
Jan 8, 2016
OK, I found a strategy I like. I am now substituting a fresh inference variable. This seems to avoid all the hazards I was concerned about. I've got a PR that works great except that |
arielb1
commented
Jan 8, 2016
Yes, I was definitely aware of scary thought the second (the reason it is not an issue in practice is subtle - the check for I feel that normalizing to the projection is fine - after all, this is what we often do when the projection contains type parameters, so the cascading error messages are not that unusual. Maybe we should just split the normalize-to-type and normalize-and-unify paths somehow, and either normalize to a projection or not unify the resulting predicate. The ICE in #4972 slightly scares me - we should investigate it. |
arielb1
commented
Jan 8, 2016
Of course, if unifying types causes more impls to be available, this can cause errors in other ways. |
…stead of `TyError`
the problem is that now "type_is_known_to_be_sized" now returns false when called on a type with ty_err inside - this prevents spurious errors (we may want to move the check to check::cast anyway - see rust-lang#12894).
nikomatsakis
commented
Jan 9, 2016
r? @arielb1 |
nikomatsakis
commented
Jan 9, 2016
This latest version now passes
I guess the last point might be silly, it does mean that we'll keep this obligation hanging around for longer. |
arielb1
commented
Jan 11, 2016
@bors r+ |
bors
commented
Jan 11, 2016
📌 Commit b0f6a47 has been approved by |
pnkfelix
commented
Jan 11, 2016
@bors p=1 (upping priority for regression fixing or beta-nominated PR's) |
bors
commented
Jan 11, 2016
⌛ Testing commit b0f6a47 with merge 19d8f46... |
bors
commented
Jan 11, 2016
💔 Test failed - auto-linux-64-nopt-t |
pnkfelix
commented
Jan 11, 2016
@bors retry |
bors
commented
Jan 11, 2016
⌛ Testing commit b0f6a47 with merge d01ed8a... |
This is an alternative to #29954 for fixing #29857 that seems to me to be more inline with the general strategy around `TyError`. It also includes the fix for #30589 -- in fact, just the minimal change of making `ty_is_local` tolerate `TyError` avoids the ICE, but you get a lot of duplicate error reports, so in the case where the impl's trait reference already includes `TyError`, we just ignore the impl altogether. cc @arielb1@sanxiynFixes#29857. Fixes#30589.
bors
commented
Jan 11, 2016
nikomatsakis
commented
Jan 11, 2016
Accepting for beta since this addresses a regression. |
This is an alternative to #29954 for fixing #29857 that seems to me to be more inline with the general strategy around
TyError. It also includes the fix for #30589 -- in fact, just the minimal change of makingty_is_localtolerateTyErroravoids the ICE, but you get a lot of duplicate error reports, so in the case where the impl's trait reference already includesTyError, we just ignore the impl altogether.cc @arielb1@sanxiyn
Fixes#29857.
Fixes#30589.