fix: Fix handling of generic params in anon consts - #23179
fix: Fix handling of generic params in anon consts #23179ChayimFriedman2 wants to merge 2 commits into
Conversation
| 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 |
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.
| } | ||
| "#, | ||
| expect![[r#" | ||
| 43..47 'self': &'? Self |
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.
| "#, | ||
| expect![[r#" | ||
| Foo[T: invariant] | ||
| Foo[T: bivariant] |
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 comment has been minimized.
This comment has been minimized.
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.
a6d7b92 to
bbb1056
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
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.