Uh oh!
There was an error while loading. Please reload this page.
Suppress fallback and ambiguity errors - #32258
Conversation
There was a problem hiding this comment.
When should this be hit? I can think of this causing damage in snapshots.
There was a problem hiding this comment.
"causing damage"
Yes, we could remove it. I don't think it's needed -- rather, we should set the flag at the source of the errors, as I later did. (I could also assert when setting the flag that we are not in a snapshot, just to be safe.)
alexcrichton
commented
Mar 15, 2016
🀄 |
nikomatsakis
commented
Mar 15, 2016
Do you see this as a problem for this patch? Can you elaborate?
Hmm, ok. What would you like it to do? Just assume true?
Because I can't unify them with ty-error. |
1739d95 to
f19c8c4Comparenikomatsakis
commented
Apr 5, 2016
@arielb1 I'm not really sure where you are in your review here. Do you think I should change something? If so, what you would you prefer? (Or if you're just busy, that's fine too.) |
arielb1
commented
Apr 6, 2016
I would prefer to just treat
I was working on a patch that didn't do Isn't cast checking the only thing downstream of default obligation? And I think we can solve it by being more careful with |
arielb1
commented
Apr 6, 2016
I was also thinking about propagating |
If the infcx has observed other errors, then suppress both default type parameter fallback (which can be unreliable, as the full constraint set is not available) and errors related to unresovled variables (annoyingly, integer type variables cannot currently be unified with error, so that has to be a separate mechanism). Also add a flag to `infcx` to allow us to independently indicate when we have observed an error and hence should trigger this suppression mode.
It is odd to have this logic strewn about. This also means that all calls to `type_is_known_to_be_sized` are encapsulated in the cast code, in case we want to update that logic.
nikomatsakis
commented
Apr 12, 2016
@arielb1 so I removed that error suppression logic out of the casts. It didn't seem to cause any new spurious errors. I decided against modifying the logic for when a type is considered sized since it didn't seem necessary. I've also gotten make check passing and rebased. Take another look and tell me what you think. Given the changes to the errors (lots of duplicates removed) this seems like a positive step to me, and I think it no longer has the invasive quality you were concerned about. |
arielb1
commented
Apr 14, 2016
Does this fix |
arielb1
commented
Apr 14, 2016
Eh, it shouldn't. Maybe put that fix in a separate PR instead? |
| // For better error messages, we try to check whether the | ||
| // target type is known to be sized now (we will also check | ||
| // later, once inference is more complete done). | ||
| if !fcx.type_is_known_to_be_sized(cast_ty, span) { |
There was a problem hiding this comment.
What is constructor doing randomly emitting error messages?
BTW, why do we need the early error message? It causes compilation errors in some cases.
There was a problem hiding this comment.
What is constructor doing randomly emitting error messages?
As you well know, a constructor is just another function... seems like as good a time as any. And the return type (in particular, the Result with ErrorReported) clearly indicates that an error is reported.
My thinking was basically that instantiating a cast check does some checks and returns, potentially, further checks that may need to be done later. I'm happy to rename.
BTW, why do we need the early error message? It causes compilation errors in some cases.
Yes, this doesn't seem optimal, I agree. I was just preserving the existing behavior -- but it seems like it could go wrong, if only in unusual situations like x as _ or x as Bar<_>
I originally moved this check to be done at the end, but then you get derived errors later. For example:
let x = foo as SomeTrait;
will give an error because the type of x is SomeTrait, which is not Sized. (Actually, it then later gives a error about "cast to unsized type".)
Probably the best thing would be to rewrite type_is_known_to_be_sized to return "yes, no, maybe" and only error out on no. (Or, for simplicity, just check specifically for casts to traits or slices, and leave the more general function for the end.)
nikomatsakis
commented
Apr 14, 2016
@arielb1 pushed a new commit that tweaks the approach. Unfortunately, this doesn't seem to be quite enough to make that test work. I didn't dig into why, but you get a "type must be known" error. |
nikomatsakis
commented
Apr 14, 2016
oh, I see, because it calls |
Do not require the target type to be fully known, either. This allows code like `let x: *const () = 0 as _` to work (see regression test).
nikomatsakis
commented
Apr 14, 2016
OK, @arielb1, pushed a new version that fixes the case you mentioned. |
nikomatsakis
commented
Apr 21, 2016
bors
commented
Apr 22, 2016
💔 Test failed - auto-win-gnu-64-opt |
arielb1
commented
Apr 22, 2016
@bors retry What the **** is going with our windows bots? |
bors
commented
Apr 22, 2016
bors
commented
Apr 22, 2016
💔 Test failed - auto-win-gnu-32-opt |
alexcrichton
commented
Apr 22, 2016
@bors: retry On Fri, Apr 22, 2016 at 8:46 AM, bors notifications@github.com wrote:
|
Suppress fallback and ambiguity errors If the infcx has observed other errors, then suppress both default type parameter fallback (which can be unreliable, as the full constraint set is not available) and errors related to unresovled variables (annoyingly, integer type variables cannot currently be unified with error, so that has to be a separate mechanism). Also add a flag to `infcx` to allow us to independently indicate when we have observed an error and hence should trigger this suppression mode. Fixesrust-lang#31997 cc @alexcrichton r? @arielb1
bors
commented
Apr 22, 2016
⌛ Testing commit 89bbd2c with merge d43fb29... |
bors
commented
Apr 23, 2016
💔 Test failed - auto-win-msvc-32-opt |
alexcrichton
commented
Apr 23, 2016
@bors: retry On Fri, Apr 22, 2016 at 5:54 PM, bors notifications@github.com wrote:
|
bors
commented
Apr 23, 2016
⌛ Testing commit 89bbd2c with merge b428b62... |
bors
commented
Apr 23, 2016
💔 Test failed - auto-win-msvc-32-opt |
alexcrichton
commented
Apr 23, 2016
@bors: retry On Fri, Apr 22, 2016 at 9:47 PM, bors notifications@github.com wrote:
|
bors
commented
Apr 23, 2016
⌛ Testing commit 89bbd2c with merge 3a44be5... |
bors
commented
Apr 23, 2016
💔 Test failed - auto-mac-64-nopt-t |
nikomatsakis
commented
Apr 25, 2016
@bors r=arielb1 |
bors
commented
Apr 25, 2016
📌 Commit b3d54a2 has been approved by |
bors
commented
Apr 25, 2016
Suppress fallback and ambiguity errors If the infcx has observed other errors, then suppress both default type parameter fallback (which can be unreliable, as the full constraint set is not available) and errors related to unresovled variables (annoyingly, integer type variables cannot currently be unified with error, so that has to be a separate mechanism). Also add a flag to `infcx` to allow us to independently indicate when we have observed an error and hence should trigger this suppression mode. Fixes#31997 cc @alexcrichton r? @arielb1
bors
commented
Apr 25, 2016
nagisa
commented
May 17, 2016
Tagging this as relnotes because of #33657 |
If the infcx has observed other errors, then suppress both default type
parameter fallback (which can be unreliable, as the full constraint set
is not available) and errors related to unresovled
variables (annoyingly, integer type variables cannot currently be
unified with error, so that has to be a separate mechanism). Also add a
flag to
infcxto allow us to independently indicate when we haveobserved an error and hence should trigger this suppression mode.
Fixes#31997
cc @alexcrichton
r? @arielb1