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

select: treat ErrorCandidate as a real error #29954

Closed
wants to merge 2 commits into from

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Nov 20, 2015

Otherwise, projection can result in type errors that are unified
into the trait inputs. We should probably refactor the
normalize_to_error mess.

We could instead change ctp::identify_constrained_type_params to put a projection's desugar selection before the projection. Would you like that better?

Fixes #29857.

r? @nikomatsakis

@sanxiyn
Copy link
Member

sanxiyn commented Nov 23, 2015

Travis failures seem real.

arielb1 and others added 2 commits November 25, 2015 17:53
Otherwise, projection can result in type errors that are unified
into the trait inputs. We should probably refactor the
`normalize_to_error` mess.
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).
@arielb1
Copy link
Contributor Author

arielb1 commented Nov 25, 2015

fixed test failures.

@nikomatsakis
Copy link
Contributor

Hmm, I'm not sure about this change. I feel like this will potentially create more downstream fallout. Is it possible that the right fix to #29857 is just to change ty_is_local_constructor to not panic and instead return true or false or maybe even a Result? This would be basically more inline with the usual error strategy, which is that when you see an error result, you should suppress all downstream errors.

OTOH maybe it's ok to have trait selection fail and we just suppress the output of failed trait selection (which I know we attempt to do anyway).

@arielb1
Copy link
Contributor Author

arielb1 commented Nov 26, 2015

@nikomatsakis

The problem is that ErrorCandidate short-circuits candidate selection, so you may accidentally end up with false positives.

@arielb1
Copy link
Contributor Author

arielb1 commented Nov 26, 2015

However, I feel like putting a ProjectionPredicate's parent TraitPredicate ahead of it in the ordering would also fix this issue. Would that be better?

@nikomatsakis
Copy link
Contributor

@arielb1

Sorry for the delay. Maybe my head just isn't in the right space anymore, but can you elaborate on this:

The problem is that ErrorCandidate short-circuits candidate selection, so you may accidentally end up with false positives.

It still seems to me that converting an Ok(ErrorCandidate) return value to an EvaluateToErr is inconsistent with our general error-handling strategy.

@nikomatsakis
Copy link
Contributor

OK, so, given that this is a stable -> beta regression, we've got to reach some decision here. I still kind of feel like this is the wrong approach, and the right approach would be to tolerate errors in the coherence code (which feels like what we normally do -- consider errors a success). But it'd be helpful @arielb1 if you could elaborate on what you meant about "false positives" and so forth.

@arielb1
Copy link
Contributor Author

arielb1 commented Dec 20, 2015

I should really be reading my e-mails more often.

The root cause of the problem here is normalize_to_error again. It means that candidate evaluation can give us some TyErrors, and if we get unlucky the TyError can mix in with the underlying selection candidate. I think that just moving the selection predicate ahead of the projection in evaluation order would fix this - I will try that later today - but I am not sure whether that is a better idea.

@nikomatsakis
Copy link
Contributor

@arielb1

I should really be reading my e-mails more often.

No worries, me too. :)

The root cause of the problem here is normalize_to_error again. It means that candidate evaluation can give us some TyErrors, and if we get unlucky the TyError can mix in with the underlying selection candidate. I think that just moving the selection predicate ahead of the projection in evaluation order would fix this - I will try that later today - but I am not sure whether that is a better idea.

So I think what you are saying here is that, but for normalize_to_error, we would not be seeing TyError at all, and if you reordered things, we might restore that invariant? That seems...fine, but it seems like being prepared for TyError is also a perfectly fine thing to do.

@arielb1
Copy link
Contributor Author

arielb1 commented Dec 22, 2015

@nikomatsakis

Right. The TyError is one of the bogus ones generated by normalize_to_error. I ended up not making that experiment.

@nikomatsakis
Copy link
Contributor

@arielb1 while on vacation I was pondering this, and I was wondering if perhaps ignoring errors in coherence (as I have been suggesting) could lead to incorrect code being accepted? Still, it's not obvious to me how this could happen, I'd expect that such an error would be reported during the WF phase. Anyway, it's clear we have to land SOME patch here. I am going to briefly experiment with a patch that is more accepting of type-error today, then we can make a final decision.

@arielb1
Copy link
Contributor Author

arielb1 commented Dec 31, 2015

@nikomatsakis

Ignoring errors in coherence should typically actually lead to less code being accepted, but this is still wrong.

bors added a commit that referenced this pull request Jan 11, 2016
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 @sanxiyn

Fixes #29857.
Fixes #30589.
@bors
Copy link
Contributor

bors commented Jan 11, 2016

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

@nikomatsakis
Copy link
Contributor

Closing in favor of #30676. Since @arielb1 r+'d I presume he has no objection, but ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants