fix: Fix handling of generic params in anon consts - #23179
Open
ChayimFriedman2 wants to merge 2 commits into
Open
fix: Fix handling of generic params in anon consts #23179ChayimFriedman2 wants to merge 2 commits into
ChayimFriedman2 wants to merge 2 commits into
Conversation
This also closes gaps we had, e.g. now `check_impl()` will include field defaults. The only changes to tests are some ordering changes due to sorting by the root expr's location now instead of the full item's location, and removal of trait functions without bodies, since they don't have a root expr. As their inference is meaningless (only the parameter types, unless you have anon consts in the parameters' patterns which we don't have in our tests), I felt safe to ignore that.
ChayimFriedman2
commented
Aug 17, 2026
| 200..206 '_other': Between<M, 0, T> | ||
| 222..242 '{ ... }': Between<M, 0, T> | ||
| 232..236 'self': Between<M, 0, T> | ||
| 320..335 '{ Consts::MAX }': usize |
Contributor
Author
There was a problem hiding this comment.
The order change is because now we sort by the root expr's location instead of the full item's.
ChayimFriedman2
commented
Aug 17, 2026
| } | ||
| "#, | ||
| expect![[r#" | ||
| 43..47 'self': &'? Self |
Contributor
Author
There was a problem hiding this comment.
Trait methods without default body are now ignored since they do not have a root expr. As their inference is meaningless (only the parameter types, unless you have anon consts in the parameters' patterns which we don't have in our tests), I felt safe to ignore that.
ChayimFriedman2
commented
Aug 17, 2026
| "#, | ||
| expect![[r#" | ||
| Foo[T: invariant] | ||
| Foo[T: bivariant] |
Contributor
Author
There was a problem hiding this comment.
Besides the fact that this code is erroneous, rustc also sees this as bivariant, as evidenced by the fact that it emits a "type parameter T is never used" error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I also took the chance to cleanup the test code for collecting infer defs.
Fixes #23175. The reason this fixes that is because the issue was the we omitted the projection from the
dyntype as we incorrectly thought it refersSelf.Best reviewed commit-by-commit.