Suppress suggest try wrap when found is unresolved infer#145707
Suppress suggest try wrap when found is unresolved infer#145707xizheyin wants to merge 2 commits intorust-lang:mainfrom
Conversation
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
|
This PR modifies |
| // when found is unresolved var, we can't suggest anything | ||
| if exp_found.found.has_type_flags(TypeFlags::HAS_INFER_TY_VAR) { |
There was a problem hiding this comment.
If you're checking for inference variables on the error path, would it make sense to do so in a way that doesn't require tracking them for all types on the happy path too?
I think the "found" type may also be very likely to have inference variables when it doesn't match the expected type, on account of how pattern type-checking works. The type of the constructor pattern is checked against the type of the scrutinee, without knowledge of what the constructor's type's generic arguments are; I think those are all left for type inference to handle. As such, I think something more targeted may be needed if the suggestion is to support types with generic arguments.
|
it seems like if the scrutinee isn't a reference while the pattern clearly is, we could try suggesting removing the |
|
@rustbot author |
|
☔ The latest upstream changes (presumably #145997) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixes #145634
In this example,
&Some((1, 2))is an&_, and we cannot know the exact type, so I think suppressing this suggestion is the most appropriate choice here. This is similar to / inspired by #145361.I expanded
TypeFlagsto indicate whether a type contains a type withis_ty_vartrue.The test with regression(#3680, #5358, #12552) are all ICE, and some are even from many years ago. Therefore, this change in PR should not have a significant impact on them?
Two commits shows the diff of the newly added test.
r? compiler