about summary refs log tree commit diff
diff options
context:
space:
mode:
authorxFrednet <xFrednet@gmail.com>2021-05-12 17:30:04 +0200
committerxFrednet <xFrednet@gmail.com>2021-05-12 17:31:00 +0200
commitb03642e51f4c1cfc51858dd792aa689b0e6597d7 (patch)
tree515c5ab4f57cecf46f2834d2b2a7281006105fb5
parent88ae2d1155c48d1c2b0dc4d049f0411778a94035 (diff)
Metadata collection clarifying default configuration values
-rw-r--r--clippy_lints/src/utils/internal_lints/metadata_collector.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs
index bb1c8ae9585..4a8a46be041 100644
--- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs
+++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs
@@ -290,12 +290,22 @@ fn collect_configs() -> Vec<ClippyConfiguration> {
                 lints,
                 doc,
                 config_type: x.config_type,
-                default: x.default.to_string(),
+                default: clarify_default(x.default),
             }
         })
         .collect()
 }
 
+fn clarify_default(default: &'static str) -> String {
+    if let Some((_start, init))  = default.split_once('[') {
+        if let Some((init, _end)) = init.split_once(']') {
+            return format!("[{}]", init);
+        }
+    }
+    
+    default.to_string()
+}
+
 /// This parses the field documentation of the config struct.
 ///
 /// ```rust, ignore