Skip to content

Commit b740a04

Browse files
committed
Metadata collection collecting configuration deprecation reason
1 parent b03642e commit b740a04

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

clippy_lints/src/utils/conf.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,20 @@ macro_rules! define_Conf {
9797
pub(crate) fn get_configuration_metadata() -> Vec<ClippyConfigurationBasicInfo> {
9898
vec![
9999
$(
100-
ClippyConfigurationBasicInfo {
101-
name: stringify!($name),
102-
config_type: stringify!($ty),
103-
default: stringify!($default),
104-
doc_comment: $doc,
100+
{
101+
#[allow(unused_mut, unused_assignments)]
102+
let mut deprecation_reason = None;
103+
104+
// only set if a deprecation reason was set
105+
$(deprecation_reason = Some(stringify!($dep));)?
106+
107+
ClippyConfigurationBasicInfo {
108+
name: stringify!($name),
109+
config_type: stringify!($ty),
110+
default: stringify!($default),
111+
doc_comment: $doc,
112+
deprecation_reason,
113+
}
105114
},
106115
)+
107116
]
@@ -118,7 +127,7 @@ define_Conf! {
118127
(blacklisted_names: Vec<String> = ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
119128
/// Lint: COGNITIVE_COMPLEXITY. The maximum cognitive complexity a function can have
120129
(cognitive_complexity_threshold: u64 = 25),
121-
/// Lint: CYCLOMATIC_COMPLEXITY. Use the Cognitive Complexity lint instead.
130+
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY. Use the Cognitive Complexity lint instead.
122131
#[conf_deprecated("Please use `cognitive-complexity-threshold` instead")]
123132
(cyclomatic_complexity_threshold: Option<u64> = None),
124133
/// Lint: DOC_MARKDOWN. The list of words this lint should not consider as identifiers needing ticks

clippy_lints/src/utils/internal_lints/metadata_collector.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ pub(crate) struct ClippyConfigurationBasicInfo {
267267
pub config_type: &'static str,
268268
pub default: &'static str,
269269
pub doc_comment: &'static str,
270+
pub deprecation_reason: Option<&'static str>,
270271
}
271272

272273
#[derive(Debug, Clone, Default)]
@@ -276,6 +277,7 @@ struct ClippyConfiguration {
276277
doc: String,
277278
config_type: &'static str,
278279
default: String,
280+
deprecation_reason: Option<&'static str>,
279281
}
280282

281283
fn collect_configs() -> Vec<ClippyConfiguration> {
@@ -291,18 +293,19 @@ fn collect_configs() -> Vec<ClippyConfiguration> {
291293
doc,
292294
config_type: x.config_type,
293295
default: clarify_default(x.default),
296+
deprecation_reason: x.deprecation_reason,
294297
}
295298
})
296299
.collect()
297300
}
298301

299302
fn clarify_default(default: &'static str) -> String {
300-
if let Some((_start, init)) = default.split_once('[') {
303+
if let Some((_start, init)) = default.split_once('[') {
301304
if let Some((init, _end)) = init.split_once(']') {
302305
return format!("[{}]", init);
303306
}
304307
}
305-
308+
306309
default.to_string()
307310
}
308311

0 commit comments

Comments
 (0)