Skip to content

Commit 9b3dcd2

Browse files
committed
Add allow-invalid configuration option for disallowed_* to the documentation
1 parent 689e62b commit 9b3dcd2

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6386,6 +6386,7 @@ Released 2018-09-13
63866386
[`allow-expect-in-consts`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-expect-in-consts
63876387
[`allow-expect-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-expect-in-tests
63886388
[`allow-indexing-slicing-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-indexing-slicing-in-tests
6389+
[`allow-invalid`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-invalid
63896390
[`allow-mixed-uninlined-format-args`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-mixed-uninlined-format-args
63906391
[`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings
63916392
[`allow-panic-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-panic-in-tests

book/src/lint_configuration.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,35 @@ Whether `indexing_slicing` should be allowed in test functions or `#[cfg(test)]`
101101
* [`indexing_slicing`](https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing)
102102

103103

104+
## `allow-invalid`
105+
Whether to allow invalid entries in disallowed_* settings
106+
107+
When this option is set to `true`, Clippy will ignore invalid entries in
108+
`disallowed_methods`, `disallowed_types`, `disallowed_macros`, etc. instead of
109+
emitting a diagnostic error.
110+
111+
#### Example
112+
113+
```toml
114+
allow-invalid = true
115+
disallowed-methods = [
116+
# This would normally error if the path is incorrect, but with allow-invalid = true,
117+
# it will be silently ignored
118+
{ path = "std::fs::InvalidPath", reason = "use alternative instead" },
119+
]
120+
```
121+
122+
**Default Value:** `false`
123+
124+
---
125+
**Affected lints:**
126+
* [`disallowed_macros`](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros)
127+
* [`disallowed_methods`](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods)
128+
* [`disallowed_names`](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names)
129+
* [`disallowed_script_idents`](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents)
130+
* [`disallowed_types`](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types)
131+
132+
104133
## `allow-mixed-uninlined-format-args`
105134
Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)`
106135

clippy_config/src/conf.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ macro_rules! define_Conf {
227227
$(#[default_text = $default_text:expr])?
228228
$(#[disallowed_paths_allow_replacements = $replacements_allowed:expr])?
229229
$(#[lints($($for_lints:ident),* $(,)?)])?
230+
$(#[allow_invalid])?
230231
$name:ident: $ty:ty = $default:expr,
231232
)*) => {
232233
/// Clippy lint configuration
@@ -369,6 +370,24 @@ define_Conf! {
369370
/// Whether `indexing_slicing` should be allowed in test functions or `#[cfg(test)]`
370371
#[lints(indexing_slicing)]
371372
allow_indexing_slicing_in_tests: bool = false,
373+
/// Whether to allow invalid entries in disallowed_* settings
374+
///
375+
/// When this option is set to `true`, Clippy will ignore invalid entries in
376+
/// `disallowed_methods`, `disallowed_types`, `disallowed_macros`, etc. instead of
377+
/// emitting a diagnostic error.
378+
///
379+
/// #### Example
380+
///
381+
/// ```toml
382+
/// allow-invalid = true
383+
/// disallowed-methods = [
384+
/// # This would normally error if the path is incorrect, but with allow-invalid = true,
385+
/// # it will be silently ignored
386+
/// { path = "std::fs::InvalidPath", reason = "use alternative instead" },
387+
/// ]
388+
/// ```
389+
#[lints(disallowed_macros, disallowed_methods, disallowed_names, disallowed_script_idents, disallowed_types)]
390+
allow_invalid: bool = false,
372391
/// Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)`
373392
#[lints(uninlined_format_args)]
374393
allow_mixed_uninlined_format_args: bool = true,

tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect
88
allow-expect-in-consts
99
allow-expect-in-tests
1010
allow-indexing-slicing-in-tests
11+
allow-invalid
1112
allow-mixed-uninlined-format-args
1213
allow-one-hash-in-raw-strings
1314
allow-panic-in-tests
@@ -100,6 +101,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect
100101
allow-expect-in-consts
101102
allow-expect-in-tests
102103
allow-indexing-slicing-in-tests
104+
allow-invalid
103105
allow-mixed-uninlined-format-args
104106
allow-one-hash-in-raw-strings
105107
allow-panic-in-tests
@@ -192,6 +194,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni
192194
allow-expect-in-consts
193195
allow-expect-in-tests
194196
allow-indexing-slicing-in-tests
197+
allow-invalid
195198
allow-mixed-uninlined-format-args
196199
allow-one-hash-in-raw-strings
197200
allow-panic-in-tests

0 commit comments

Comments
 (0)