Fix ICE: can't type-check body of DefId for issue #150956 #151085
+26
−6
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.
This PR fixes #150956 for min_const_generic_args #132980.
The first part of this PR checks in
reachable.rsif we have a type const usevisit_const_item_rhs(init);instead of callingconst_eval_poly_to_alloc()The second part is I noticed that if
const_eval_poly_to_alloc()returns aErrorHandled::TooGenericthen switches tovisit_const_item_rhs(). So further upconst_eval_poly_to_alloc()call order it eventual gets toeval_in_interpreter(). So I added a check ineval_in_interpreter()to return aErrorHandled::TooGeneric, for any other logic similar to what I observed inreachable.rsor at least allow that logic report some kinda of error.The other bit is just a test case, and some duplicated code I noticed.
While the PR does get rid of the ICE for a type_const with
pubvisibility. If I try using the const though it will ICE with the following:I suspect it is a similar issue to inherent associated consts. Since if I apply the same fix I had here:
#150799 (comment)
I then can use the const internally and in external crates without any issues.
Although, did not include that fix since if it is a similar issue it would need to be addressed elsewhere.
r? @BoxyUwU
@rustbot label +F-associated_const_equality +F-min_generic_const_args