diff options
| author | xFrednet <xFrednet@gmail.com> | 2021-05-12 18:47:32 +0200 |
|---|---|---|
| committer | xFrednet <xFrednet@gmail.com> | 2021-05-12 18:47:32 +0200 |
| commit | b740a04dc49b32185e69a2128bcb8425d82b0c66 (patch) | |
| tree | 689f0c07d5522d92adaf66d831e542a2bd095aeb | |
| parent | b03642e51f4c1cfc51858dd792aa689b0e6597d7 (diff) | |
| download | rust-b740a04dc49b32185e69a2128bcb8425d82b0c66.tar.gz rust-b740a04dc49b32185e69a2128bcb8425d82b0c66.zip | |
Metadata collection collecting configuration deprecation reason
| -rw-r--r-- | clippy_lints/src/utils/conf.rs | 21 | ||||
| -rw-r--r-- | clippy_lints/src/utils/internal_lints/metadata_collector.rs | 7 |
2 files changed, 20 insertions, 8 deletions
diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 98b86f73a1f..25163bb9f37 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -97,11 +97,20 @@ macro_rules! define_Conf { pub(crate) fn get_configuration_metadata() -> Vec<ClippyConfigurationBasicInfo> { vec![ $( - ClippyConfigurationBasicInfo { - name: stringify!($name), - config_type: stringify!($ty), - default: stringify!($default), - doc_comment: $doc, + { + #[allow(unused_mut, unused_assignments)] + let mut deprecation_reason = None; + + // only set if a deprecation reason was set + $(deprecation_reason = Some(stringify!($dep));)? + + ClippyConfigurationBasicInfo { + name: stringify!($name), + config_type: stringify!($ty), + default: stringify!($default), + doc_comment: $doc, + deprecation_reason, + } }, )+ ] @@ -118,7 +127,7 @@ define_Conf! { (blacklisted_names: Vec<String> = ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()), /// Lint: COGNITIVE_COMPLEXITY. The maximum cognitive complexity a function can have (cognitive_complexity_threshold: u64 = 25), - /// Lint: CYCLOMATIC_COMPLEXITY. Use the Cognitive Complexity lint instead. + /// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY. Use the Cognitive Complexity lint instead. #[conf_deprecated("Please use `cognitive-complexity-threshold` instead")] (cyclomatic_complexity_threshold: Option<u64> = None), /// Lint: DOC_MARKDOWN. The list of words this lint should not consider as identifiers needing ticks diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 4a8a46be041..bd0de8ad034 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -267,6 +267,7 @@ pub(crate) struct ClippyConfigurationBasicInfo { pub config_type: &'static str, pub default: &'static str, pub doc_comment: &'static str, + pub deprecation_reason: Option<&'static str>, } #[derive(Debug, Clone, Default)] @@ -276,6 +277,7 @@ struct ClippyConfiguration { doc: String, config_type: &'static str, default: String, + deprecation_reason: Option<&'static str>, } fn collect_configs() -> Vec<ClippyConfiguration> { @@ -291,18 +293,19 @@ fn collect_configs() -> Vec<ClippyConfiguration> { doc, config_type: x.config_type, default: clarify_default(x.default), + deprecation_reason: x.deprecation_reason, } }) .collect() } fn clarify_default(default: &'static str) -> String { - if let Some((_start, init)) = default.split_once('[') { + if let Some((_start, init)) = default.split_once('[') { if let Some((init, _end)) = init.split_once(']') { return format!("[{}]", init); } } - + default.to_string() } |
