fix: Do not infer signatures, instead infer anon consts in them#22198
fix: Do not infer signatures, instead infer anon consts in them#22198ChayimFriedman2 wants to merge 2 commits intorust-lang:masterfrom
Conversation
| 223..227 'iter': IntoIter<u8> | ||
| 230..231 'a': Vec<u8> | ||
| 230..243 'a.into_iter()': IntoIter<u8> | ||
| 322..323 '1': usize |
There was a problem hiding this comment.
Previously we inferred all expressions in the signature. Now we skip literals and paths (we don't create an anon const for them) to save time and space. The net effect is that they aren't shown in tests and to IDE, although it's possibly to support them for IDE in little effort.
| ); | ||
| // note: this may break later if we add more consteval. it just needs to be something that our | ||
| // consteval engine doesn't understand | ||
| check_assist_not_applicable( |
There was a problem hiding this comment.
It's not easy to support this now, since the type does not contain an error type anymore: it just has an anon const that fails to evaluate, which causes it to fail to normalize. But I've realized this test is no longer needed, since _ in arrays is supported by now.
047f10d to
372b99f
Compare
This comment has been minimized.
This comment has been minimized.
372b99f to
f74e82e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f74e82e to
b5b1afd
Compare
This comment has been minimized.
This comment has been minimized.
b5b1afd to
d9151a7
Compare
This comment has been minimized.
This comment has been minimized.
See [the Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/Anon.20consts.20for.20everything/with/587684630) for details, but in short: - This allows us to easily set the expected type. - They can have proper MIR an eval, preventing the need for hacks like `fixme_resolve_all_clone()`. This also fixes a bunch of old inference failures caused by us unable to evaluate constants. In order to make them visible to the IDE layer, each query that can create anon consts now keeps a list of the anon consts it created. The expression store also gains an ability to find the root expression of something. Then, in `Semantics`, when wanting to find inference info for something, we find its root expr, then search it in the list of anon consts defined by the body.
d9151a7 to
e6823d8
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. |
See the Zulip discussion for details, but in short:
fixme_resolve_all_clone().This also fixes a bunch of old inference failures caused by us unable to evaluate constants.
In order to make them visible to the IDE layer, each query that can create anon consts now keeps a list of the anon consts it created. The expression store also gains an ability to find the root expression of something. Then, in
Semantics, when wanting to find inference info for something, we find its root expr, then search it in the list of anon consts defined by the body.This should reduce our diagnostics on self by at least two (they're caused by failure to evaluate consts on
to_le_bytes(), we even have a test for that).Blocked on #22194.