Skip to content

fix: remove angle brackets if all lifetime args removed in inline type alias code assist.#21784

Open
80avin wants to merge 1 commit intorust-lang:masterfrom
80avin:fix-inline-type-assist
Open

fix: remove angle brackets if all lifetime args removed in inline type alias code assist.#21784
80avin wants to merge 1 commit intorust-lang:masterfrom
80avin:fix-inline-type-assist

Conversation

@80avin
Copy link

@80avin 80avin commented Mar 8, 2026

fixes #21769

In Inline type alias into all uses code assist,

  • Remove comma and whitespace along with lifetime arg
  • cleanup empty angle brackets

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 8, 2026
@80avin 80avin force-pushed the fix-inline-type-assist branch 2 times, most recently from 8a5706a to d181b85 Compare March 8, 2026 21:09
&& ws.kind() == SyntaxKind::WHITESPACE
{
removals.push(ws);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When deleting multiple parameters but the list is not cleared, the comma has not been deleted yet
Similar code (needs removals.unique()):

removals.extend(next_prev().find_map(|dir| {
    let tokens = syntax.siblings_with_tokens(dir)
        .take_while(|it| it.is_token())
        .take_while_inclusive(|it| it.kind() != T![,])
        .collect::<Vec<_>>();
    tokens.iter().any(|it| it.kind() == T![,]).then_some(tokens)
}).flatten())

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Also added one more test case.
Please resolve if it seems right.

.syntax()
.parent()
.and_then(ast::GenericArgList::cast)
.is_some()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this condition always true?

Copy link
Author

@80avin 80avin Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know that LifetimeArg is always a child of GenericArgList.
Fixed. Please resolve if it appears right.

@80avin 80avin force-pushed the fix-inline-type-assist branch from d181b85 to 286402c Compare March 15, 2026 19:41
@80avin 80avin force-pushed the fix-inline-type-assist branch from 286402c to c6912a1 Compare March 15, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

“Inline type alias into all uses” creates syntax errors for type aliases with lifetimes omitted at the use site

3 participants