diff options
| author | bors <bors@rust-lang.org> | 2024-04-30 12:09:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-30 12:09:34 +0000 |
| commit | 4ce1c6cb97f31f8b527a11e5b0d206319c599490 (patch) | |
| tree | d7d1dfaa6b3101c8127f419cc6eaa0939ef71c0f /tests/codegen/patchable-function-entry/patchable-function-entry-both-flags.rs | |
| parent | 27fa5639c3647203baab8ef10952f28e4c387013 (diff) | |
| parent | e2b1c552550d04b59ad3692ebeef84a95c7ba62a (diff) | |
| download | rust-4ce1c6cb97f31f8b527a11e5b0d206319c599490.tar.gz rust-4ce1c6cb97f31f8b527a11e5b0d206319c599490.zip | |
Auto merge of #17138 - Kohei316:generate-function-assist-for-new, r=Veykril
feature: Make generate function assist generate a function as a constructor if the generated function has the name "new" and is an asscociated function.
close #17050
This PR makes `generate function assist` generate a function as a constructor if the generated function has the name "new" and is an asscociated function.
If the asscociate type is a record struct, it generates the constructor like this.
```rust
impl Foo {
fn new() -> Self {
Self { field_1: todo!(), field_2: todo!() }
}
}
```
If the asscociate type is a tuple struct, it generates the constructor like this.
```rust
impl Foo {
fn new() -> Self {
Self(todo!(), todo!())
}
}
```
If the asscociate type is a unit struct, it generates the constructor like this.
```rust
impl Foo {
fn new() -> Self {
Self
}
}
```
If the asscociate type is another adt, it generates the constructor like this.
```rust
impl Foo {
fn new() -> Self {
todo!()
}
}
```
Diffstat (limited to 'tests/codegen/patchable-function-entry/patchable-function-entry-both-flags.rs')
0 files changed, 0 insertions, 0 deletions
