Fix extract_type_alias and provide inlay hints for const _ placeholders#22211
Open
nicolas-guichard wants to merge 3 commits into
Open
Fix extract_type_alias and provide inlay hints for const _ placeholders#22211nicolas-guichard wants to merge 3 commits into
_ placeholders#22211nicolas-guichard wants to merge 3 commits into
Conversation
aac49b9 to
5980265
Compare
Contributor
|
I have a branch that rewrites how we collect placeholders to be more principled (pass the table and the |
Contributor
Author
|
Oh right, thanks! |
5980265 to
0a4871a
Compare
This comment has been minimized.
This comment has been minimized.
0a4871a to
50c8743
Compare
This comment has been minimized.
This comment has been minimized.
50c8743 to
fe0a73b
Compare
This comment has been minimized.
This comment has been minimized.
fe0a73b to
f50633f
Compare
This comment has been minimized.
This comment has been minimized.
f50633f to
07a60fd
Compare
This comment has been minimized.
This comment has been minimized.
07a60fd to
8ee1191
Compare
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
@ChayimFriedman2 Now that your other PRs are merged, would you have some time to review this? |
8ee1191 to
a3edee3
Compare
This comment has been minimized.
This comment has been minimized.
a3edee3 to
36c1a5c
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
36c1a5c to
3de72a4
Compare
This comment has been minimized.
This comment has been minimized.
This extends InferenceResult with a new const_of_const_placeholders map
to record which const a given const or type placeholder gets resolved
to.
This is basically the same as type_of_type_placeholder, but for consts.
Note that while surprising, TypeRef::Placeholder may indeed resolve to
a const because except for arrays the parser doesn't know ahead of type
if a _ will resolve to a type or a const.
In the case of an array, we have an Expr::Underscore:
```
let a: [_; _] = [4, 5, 6];
//^ TypeRef::Placeholder that resolves to the type i32
//^ Expr::Underscore that resolves to the const 3
```
But for a struct we have a TypeRef::Placeholder:
```
struct S<T, const N: usize>([T; N]);
let s: S<_, _> = S([1, 2, 3]);
//^ TypeRef::Placeholder that resolves to the type i32
//^ TypeRef::Placeholder that resolves to the const 3
```
This fixes SourceAnalyzer::type_of_type to replace const infer vars in types with their resolved value.
This provides an inlay hint for _ in const generic arguments.
3de72a4 to
bd92ba5
Compare
Collaborator
|
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. |
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.
This is basically the extension of #20125 to const generics.
Before:

After:

Blocked on #22237.