about summary refs log tree commit diff
path: root/editors/code
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-01-07 14:10:11 +0000
committerGitHub <noreply@github.com>2022-01-07 14:10:11 +0000
commit40009e07d002bf676b4b32e90a858aed37ea4cc2 (patch)
tree03cbb6821b271c292ed6a206c83367d60292be21 /editors/code
parentefb9b89163e4a6080f5d87133028de28cbaf310c (diff)
parent8e0a05eb70d2a3506e1441fb491c0f8b6ae4ac59 (diff)
downloadrust-40009e07d002bf676b4b32e90a858aed37ea4cc2.tar.gz
rust-40009e07d002bf676b4b32e90a858aed37ea4cc2.zip
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json13
1 files changed, 13 insertions, 0 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index d4188684748..2c7d6c3773e 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -378,6 +378,19 @@
                     "markdownDescription": "Optional settings passed to the debug engine. Example: `{ \"lldb\": { \"terminal\":\"external\"} }`"
                 },
                 "$generated-start": {},
+                "rust-analyzer.assist.exprFillDefault": {
+                    "markdownDescription": "Placeholder for missing expressions in assists.",
+                    "default": "todo",
+                    "type": "string",
+                    "enum": [
+                        "todo",
+                        "default"
+                    ],
+                    "enumDescriptions": [
+                        "Fill missing expressions with the `todo` macro",
+                        "Fill missing expressions with reasonable defaults, `new` or `default` constructors."
+                    ]
+                },
                 "rust-analyzer.assist.importGranularity": {
                     "markdownDescription": "How imports should be grouped into use statements.",
                     "default": "crate",