Skip to content

feat: add .new postfix completion based on expected type (rust-lang/r…#22132

Merged
A4-Tacks merged 1 commit intorust-lang:masterfrom
Amit5601:feat-postfix-new
Apr 23, 2026
Merged

feat: add .new postfix completion based on expected type (rust-lang/r…#22132
A4-Tacks merged 1 commit intorust-lang:masterfrom
Amit5601:feat-postfix-new

Conversation

@Amit5601
Copy link
Copy Markdown
Contributor

@Amit5601 Amit5601 commented Apr 22, 2026

Fixes #20851
Added a .new postfix completion to easily construct types when the expected type is known.
Added the postfix_new unit test to verify it triggers correctly.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 22, 2026
@Amit5601 Amit5601 marked this pull request as draft April 22, 2026 01:18
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 22, 2026
postfix_snippet("call", "function(expr)", &format!("${{1}}({receiver_text})"))
.add_to(acc, ctx.db);
if let Some(expected_ty) = ctx.expected_type.as_ref() {
let ty_name = expected_ty.display(ctx.db, ctx.display_target).to_string();
Copy link
Copy Markdown
Member

@A4-Tacks A4-Tacks Apr 22, 2026

Choose a reason for hiding this comment

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

In an ideal situation, this should determine whether there is a new method, if there is one parameter, and if the types match

View changes since the review

@Amit5601 Amit5601 marked this pull request as ready for review April 23, 2026 01:30
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 23, 2026
@Amit5601 Amit5601 requested a review from A4-Tacks April 23, 2026 01:30
@A4-Tacks A4-Tacks added this pull request to the merge queue Apr 23, 2026
Merged via the queue into rust-lang:master with commit 4171602 Apr 23, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic postfix new completion

3 participants