Rust: Strengthen isNotInstantiationOf uses
#21010
Merged
+198
−100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Consider the following example
Inside
test, the variablexis assigned both typesi32(the default type for integer literals) andusize(because of the return type), because we do not currently support context-based typing of literals.This means that the call
x.fcan resolve to bothi32fandusizef. However, because of how we construct candidate receiver types, we also conclude that&usizeand&i32need to be considered, which means we also resolvex.ftoReff, and then because of the self-assignment, this will lead to an explosion in inferred types forx.The solution, in the case above, is to tweak how we construct candidate receiver types, by only checking non-compatibility for non-root types.
Note that this does not resolve the issue with
xhaving both typesi32andusize, and hencex.fhaving two targets.DCA is rather uneventful.