Skip to content

Commit 4998130

Browse files
committed
Fix config parsing
1 parent 857d9f1 commit 4998130

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

clippy_lints/src/utils/conf.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ macro_rules! define_Conf {
2828
($(
2929
#[$doc:meta]
3030
$(#[conf_deprecated($dep:literal)])?
31-
($name:ident: $ty:ty $(= $default:expr)?),
31+
($name:ident: $ty:ty = $default:expr),
3232
)*) => {
3333
/// Clippy lint configuration
3434
pub struct Conf {
3535
$(#[$doc] pub $name: $ty,)*
3636
}
3737

3838
mod defaults {
39-
$(pub fn $name() -> $ty { define_Conf!(@default $($default)?) })*
39+
$(pub fn $name() -> $ty { $default })*
4040
}
4141

4242
impl Default for Conf {
@@ -90,20 +90,19 @@ macro_rules! define_Conf {
9090
}
9191
}
9292
};
93-
(@default) => (Default::default());
94-
(@default $default:expr) => ($default);
9593
}
9694

95+
// N.B., this macro is parsed by util/lintlib.py
9796
define_Conf! {
9897
/// Lint: CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR. The minimum rust version that the project supports
99-
(msrv: Option<String>),
98+
(msrv: Option<String> = None),
10099
/// Lint: BLACKLISTED_NAME. The list of blacklisted names to lint about. NB: `bar` is not here since it has legitimate uses
101100
(blacklisted_names: Vec<String> = ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
102101
/// Lint: COGNITIVE_COMPLEXITY. The maximum cognitive complexity a function can have
103102
(cognitive_complexity_threshold: u64 = 25),
104103
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY. Use the Cognitive Complexity lint instead.
105104
#[conf_deprecated("Please use `cognitive-complexity-threshold` instead")]
106-
(cyclomatic_complexity_threshold: Option<u64>),
105+
(cyclomatic_complexity_threshold: Option<u64> = None),
107106
/// Lint: DOC_MARKDOWN. The list of words this lint should not consider as identifiers needing ticks
108107
(doc_valid_idents: Vec<String> = [
109108
"KiB", "MiB", "GiB", "TiB", "PiB", "EiB",
@@ -142,7 +141,7 @@ define_Conf! {
142141
/// Lint: DECIMAL_LITERAL_REPRESENTATION. The lower bound for linting decimal literals
143142
(literal_representation_threshold: u64 = 16384),
144143
/// Lint: TRIVIALLY_COPY_PASS_BY_REF. The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by reference.
145-
(trivial_copy_size_limit: Option<u64>),
144+
(trivial_copy_size_limit: Option<u64> = None),
146145
/// Lint: LARGE_TYPE_PASS_BY_MOVE. The minimum size (in bytes) to consider a type for passing by reference instead of by value.
147146
(pass_by_value_size_limit: u64 = 256),
148147
/// Lint: TOO_MANY_LINES. The maximum number of lines a function or method can have
@@ -158,15 +157,15 @@ define_Conf! {
158157
/// Lint: FN_PARAMS_EXCESSIVE_BOOLS. The maximum number of bools function parameters can have
159158
(max_fn_params_bools: u64 = 3),
160159
/// Lint: WILDCARD_IMPORTS. Whether to allow certain wildcard imports (prelude, super in tests).
161-
(warn_on_all_wildcard_imports: bool),
160+
(warn_on_all_wildcard_imports: bool = false),
162161
/// Lint: DISALLOWED_METHOD. The list of disallowed methods, written as fully qualified paths.
163-
(disallowed_methods: Vec<String>),
162+
(disallowed_methods: Vec<String> = Vec::new()),
164163
/// Lint: UNREADABLE_LITERAL. Should the fraction of a decimal be linted to include separators.
165164
(unreadable_literal_lint_fractions: bool = true),
166165
/// Lint: UPPER_CASE_ACRONYMS. Enables verbose mode. Triggers if there is more than one uppercase char next to each other
167-
(upper_case_acronyms_aggressive: bool),
166+
(upper_case_acronyms_aggressive: bool = false),
168167
/// Lint: _CARGO_COMMON_METADATA. For internal testing only, ignores the current `publish` settings in the Cargo manifest.
169-
(cargo_ignore_publish: bool),
168+
(cargo_ignore_publish: bool = false),
170169
}
171170

172171
/// Search for the configuration file.

util/lintlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
group_re = re.compile(r'''\s*([a-z_][a-z_0-9]+)''')
1515
conf_re = re.compile(r'''define_Conf! {\n([^}]*)\n}''', re.MULTILINE)
1616
confvar_re = re.compile(
17-
r'''/// Lint: ([\w,\s]+)\. (.*)\n\s*\([^,]+,\s+"([^"]+)":\s+([^,]+),\s+([^\.\)]+).*\),''', re.MULTILINE)
17+
r'''/// Lint: ([\w,\s]+)\. (.*)\n\s*\(([^:]+):\s*([^\s=]+)\s*=\s*([^\.\)]+).*\),''', re.MULTILINE)
1818
comment_re = re.compile(r'''\s*/// ?(.*)''')
1919

2020
lint_levels = {

0 commit comments

Comments
 (0)