Skip to content

Add auto trait name for generate_trait_from_impl #20299

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 1 commit into
base: master
Choose a base branch
from

Conversation

A4-Tacks
Copy link
Contributor

Auto generate trait name from first method.

Input:

impl S$0 {
    fn foo() {}
}

Old output:

trait NewTrait {
    fn foo();
}

impl NewTrait for S {
    fn foo() {}
}

This PR output:

trait Foo {
    fn foo();
}

impl Foo for S {
    fn foo() {}
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 24, 2025
@ChayimFriedman2
Copy link
Contributor

Why specifically from the first method, or from methods at all? I'm not sure this is advantageous.

@A4-Tacks
Copy link
Contributor Author

Having placeholder snippet group, incorrect name is irrelevant

Auto generate trait name from first method.

Input:

```rust
impl S$0 {
    fn foo() {}
}
```

Old output:

```rust
trait NewTrait {
    fn foo();
}

impl NewTrait for S {
    fn foo() {}
}
```

This PR output:

```rust
trait Foo {
    fn foo();
}

impl Foo for S {
    fn foo() {}
}
```
@A4-Tacks A4-Tacks force-pushed the auto-trait-name-for-gen-trait-from-impl branch from c992237 to 70552cb Compare July 24, 2025 10:29
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.

3 participants