-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Feature request: Inline type alias #10881
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
Comments
Was thinking about this yesterday, would’ve been nice for rustls/rustls#895. |
I'll try to implement this. |
11690: feat: Add an assist for inlining type aliases r=Veykril a=steven-joruk I'm working towards implementing #10881, but I'd like to get this in first with earlier feedback. Is `inline_type_alias` a good enough name? I guess the follow up assist would be called `inline_type_alias_into_all_users` based on that.   Co-authored-by: Steven Joruk <[email protected]>
@Veykril It seems we can close this issue? |
Hey @hi-rustin, #11690 only added inlining a single instance of a type alias use, this feature also requests inlining the definition to all users. |
I'm going to try this one |
Hi @steven-joruk! Currently I'm trying to implement You added a nice test: rust-analyzer/crates/ide-assists/src/handlers/inline_type_alias.rs Lines 385 to 398 in 49700e4
which shows that the current implementation can't inline such alias uses. IIUC, this happens because Could you please explain, why |
An So to support inlining on usages, we should be checking |
Besides calling an associated function on an aliased type, there seems to be a lot of other usages. (Enum variant, Record expression, etc) What is more important that needs to be done first, cover as much usages as possible in By the way, I'm not sure I understand, what does |
A Path is just something like It doesnt really matter what you improve herefirst, thats up to you |
…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
Similar to "Inline
function
" / "Inline into all callers", it would be nice if there was "Inlinetypealias
" and "Inline into all uses" for type aliases.The text was updated successfully, but these errors were encountered: