Skip to content

Add ide-assist: generate_impl_trait for generate_impl #19938

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

A4-Tacks
Copy link
Contributor

@A4-Tacks A4-Tacks commented Jun 6, 2025

Adds this trait impl for a type.

trait $0Foo {
    fn foo(&self) -> i32;
}

->

trait Foo {
    fn foo(&self) -> i32;
}

impl Foo for ${1:_} {
    $0fn foo(&self) -> i32 {
        todo!()
    }
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 6, 2025
@A4-Tacks A4-Tacks changed the title Add generate_impl_trait for generate_impl ide-assist: Add ide-assist: generate_impl_trait for generate_impl Jun 6, 2025
@A4-Tacks A4-Tacks changed the title ide-assist: Add ide-assist: generate_impl_trait for generate_impl Add ide-assist: generate_impl_trait for generate_impl Jun 6, 2025
@A4-Tacks
Copy link
Contributor Author

r? @Veykril

}

impl Foo<${1:_}> for ${2:_} {
$0fn foo(&self) -> _ {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a tabstop here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used to fill in generic parameters?

Copy link
Member

@ShoyuVanilla ShoyuVanilla Jun 28, 2025

Choose a reason for hiding this comment

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

I mean, before the fn keyword

@ShoyuVanilla
Copy link
Member

Besides tabstop, other things look good

@Veykril Veykril removed their assignment Jun 27, 2025
}

if let Some(item) = impl_.assoc_item_list().and_then(|it| it.assoc_items().next()) {
edit.add_tabstop_before(cap, item);
Copy link
Member

Choose a reason for hiding this comment

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

I was confused because I'm in my phone outside 😅

I mean, do we need this tabstop before the first assoc item of a trait?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When implementing traits, positioning the cursor nearby is more convenient for editing todo!()

Copy link
Member

Choose a reason for hiding this comment

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

Then the tabstop should probably be on the todo!()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then the tabstop should probably be on the todo!()

ok

@A4-Tacks A4-Tacks requested a review from Veykril June 30, 2025 02:31
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.

4 participants