fix: Do not infer signatures, instead infer anon consts in them#22198
Open
ChayimFriedman2 wants to merge 2 commits intorust-lang:masterfrom
Open
fix: Do not infer signatures, instead infer anon consts in them#22198ChayimFriedman2 wants to merge 2 commits intorust-lang:masterfrom
ChayimFriedman2 wants to merge 2 commits intorust-lang:masterfrom
Conversation
ChayimFriedman2
commented
Apr 27, 2026
| 223..227 'iter': IntoIter<u8> | ||
| 230..231 'a': Vec<u8> | ||
| 230..243 'a.into_iter()': IntoIter<u8> | ||
| 322..323 '1': usize |
Contributor
Author
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.
ChayimFriedman2
commented
Apr 27, 2026
| ); | ||
| // 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( |
Contributor
Author
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.
0a2eb35 to
047f10d
Compare
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.
047f10d to
372b99f
Compare
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.
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.