-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Suppress fallback and ambiguity errors #32258
Conversation
@@ -86,6 +86,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> { | |||
} | |||
|
|||
(&ty::TyError, _) | (_, &ty::TyError) => { | |||
infcx.set_tainted_by_errors(); |
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.
When should this be hit? I can think of this causing damage in snapshots.
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.
"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.)
🀄 |
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
f19c8c4
Compare
@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.) |
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 |
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.
77c7754
to
2c9dfaf
Compare
@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. |
Does this fix |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.)
@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. |
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).
86a1274
to
89bbd2c
Compare
OK, @arielb1, pushed a new version that fixes the case you mentioned. |
💔 Test failed - auto-win-gnu-64-opt |
@bors retry What the **** is going with our windows bots? |
💔 Test failed - auto-win-gnu-32-opt |
@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. Fixes rust-lang#31997 cc @alexcrichton r? @arielb1
⌛ Testing commit 89bbd2c with merge d43fb29... |
💔 Test failed - auto-win-msvc-32-opt |
@bors: retry On Fri, Apr 22, 2016 at 5:54 PM, bors notifications@github.com wrote:
|
⌛ Testing commit 89bbd2c with merge b428b62... |
💔 Test failed - auto-win-msvc-32-opt |
@bors: retry On Fri, Apr 22, 2016 at 9:47 PM, bors notifications@github.com wrote:
|
⌛ Testing commit 89bbd2c with merge 3a44be5... |
💔 Test failed - auto-mac-64-nopt-t |
@bors r=arielb1 |
📌 Commit b3d54a2 has been approved by |
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
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
infcx
to allow us to independently indicate when we haveobserved an error and hence should trigger this suppression mode.
Fixes #31997
cc @alexcrichton
r? @arielb1