-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: Add an assist for inlining all type alias uses #13036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add an assist for inlining all type alias uses #13036
Conversation
One test (
Expected output:
Actual:
I'm not familiar with the way it is being tested, @Veykril, maybe you can help. |
The output will only render files that have changed content, so |
.into_iter() | ||
.filter_map(|file_ref| match file_ref.name { | ||
ast::NameLike::NameRef(path_type) => { | ||
path_type.syntax().ancestors().find_map(ast::PathType::cast) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might hit some paths that it shouldn't right now, like T::Assoc
where T is what we inline. In this case we should just go with path_type.syntax().ancestors().nth(3).and_then(ast::Pathtype::cast)
. We take the third ancestor because of the following hierarchy, NameRef -> PathSegment -> Path -> PathType
. As this assist currently only supports single segment path types, so we should make sure to only pick those here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, fixed!
Thanks! |
…ykril feat: Add an assist for inlining all type alias uses ## Description `inline_type_alias_uses` assist tries to inline all selected type alias occurrences. ### Currently Type alias used in `PathType` position are inlined. ### Not supported - Removing type alias declaration if all uses are inlined. - Removing redundant imports after inlining all uses in the file. - Type alias not in `PathType` position, such as: - `A::new()` - `let x = A {}` - `let bits = A::BITS` - etc. ## Demonstration  ## Related Issues Partially fixes #10881
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
The first two "not supported" are now supported in #13091 |
Description
inline_type_alias_uses
assist tries to inline all selected type alias occurrences.Currently
Type alias used in
PathType
position are inlined.Not supported
PathType
position, such as:A::new()
let x = A {}
let bits = A::BITS
Demonstration
Related Issues
Partially fixes #10881