Skip to content

Commit 0bac1ca

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

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

book/src/lint_configuration.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,13 @@ The maximum cognitive complexity a function can have
478478
## `disallowed-macros`
479479
The list of disallowed macros, written as fully qualified paths.
480480

481+
**Fields:**
482+
- `path` (required): the fully qualified path to the macro that should be disallowed
483+
- `reason` (optional): explanation why this macro is disallowed
484+
- `replacement` (optional): suggested alternative macro
485+
- `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
486+
if the path doesn't exist, instead of emitting an error
487+
481488
**Default Value:** `[]`
482489

483490
---
@@ -488,6 +495,13 @@ The list of disallowed macros, written as fully qualified paths.
488495
## `disallowed-methods`
489496
The list of disallowed methods, written as fully qualified paths.
490497

498+
**Fields:**
499+
- `path` (required): the fully qualified path to the method that should be disallowed
500+
- `reason` (optional): explanation why this method is disallowed
501+
- `replacement` (optional): suggested alternative method
502+
- `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
503+
if the path doesn't exist, instead of emitting an error
504+
491505
**Default Value:** `[]`
492506

493507
---
@@ -510,6 +524,13 @@ default configuration of Clippy. By default, any configuration will replace the
510524
## `disallowed-types`
511525
The list of disallowed types, written as fully qualified paths.
512526

527+
**Fields:**
528+
- `path` (required): the fully qualified path to the type that should be disallowed
529+
- `reason` (optional): explanation why this type is disallowed
530+
- `replacement` (optional): suggested alternative type
531+
- `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
532+
if the path doesn't exist, instead of emitting an error
533+
513534
**Default Value:** `[]`
514535

515536
---

clippy_config/src/conf.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,24 @@ define_Conf! {
572572
#[conf_deprecated("Please use `cognitive-complexity-threshold` instead", cognitive_complexity_threshold)]
573573
cyclomatic_complexity_threshold: u64 = 25,
574574
/// The list of disallowed macros, written as fully qualified paths.
575+
///
576+
/// **Fields:**
577+
/// - `path` (required): the fully qualified path to the macro that should be disallowed
578+
/// - `reason` (optional): explanation why this macro is disallowed
579+
/// - `replacement` (optional): suggested alternative macro
580+
/// - `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
581+
/// if the path doesn't exist, instead of emitting an error
575582
#[disallowed_paths_allow_replacements = true]
576583
#[lints(disallowed_macros)]
577584
disallowed_macros: Vec<DisallowedPath> = Vec::new(),
578585
/// The list of disallowed methods, written as fully qualified paths.
586+
///
587+
/// **Fields:**
588+
/// - `path` (required): the fully qualified path to the method that should be disallowed
589+
/// - `reason` (optional): explanation why this method is disallowed
590+
/// - `replacement` (optional): suggested alternative method
591+
/// - `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
592+
/// if the path doesn't exist, instead of emitting an error
579593
#[disallowed_paths_allow_replacements = true]
580594
#[lints(disallowed_methods)]
581595
disallowed_methods: Vec<DisallowedPath> = Vec::new(),
@@ -585,6 +599,13 @@ define_Conf! {
585599
#[lints(disallowed_names)]
586600
disallowed_names: Vec<String> = DEFAULT_DISALLOWED_NAMES.iter().map(ToString::to_string).collect(),
587601
/// The list of disallowed types, written as fully qualified paths.
602+
///
603+
/// **Fields:**
604+
/// - `path` (required): the fully qualified path to the type that should be disallowed
605+
/// - `reason` (optional): explanation why this type is disallowed
606+
/// - `replacement` (optional): suggested alternative type
607+
/// - `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
608+
/// if the path doesn't exist, instead of emitting an error
588609
#[disallowed_paths_allow_replacements = true]
589610
#[lints(disallowed_types)]
590611
disallowed_types: Vec<DisallowedPath> = Vec::new(),

clippy_lints/src/disallowed_macros.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ declare_clippy_lint! {
3838
/// # When using an inline table, can add a `reason` for why the macro
3939
/// # is disallowed.
4040
/// { path = "serde::Serialize", reason = "no serializing" },
41+
/// # This would normally error if the path is incorrect, but with `allow-invalid` = `true`,
42+
/// # it will be silently ignored
43+
/// { path = "std::invalid_macro", reason = "use alternative instead", allow-invalid = true }
4144
/// ]
4245
/// ```
4346
/// ```no_run

clippy_lints/src/disallowed_methods.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ declare_clippy_lint! {
3333
/// { path = "std::vec::Vec::leak", reason = "no leaking memory" },
3434
/// # Can also add a `replacement` that will be offered as a suggestion.
3535
/// { path = "std::sync::Mutex::new", reason = "prefer faster & simpler non-poisonable mutex", replacement = "parking_lot::Mutex::new" },
36+
/// # This would normally error if the path is incorrect, but with `allow-invalid` = `true`,
37+
/// # it will be silently ignored
38+
/// { path = "std::fs::InvalidPath", reason = "use alternative instead", allow-invalid = true },
3639
/// ]
3740
/// ```
3841
///

clippy_lints/src/disallowed_types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ declare_clippy_lint! {
3434
/// { path = "std::net::Ipv4Addr", reason = "no IPv4 allowed" },
3535
/// # Can also add a `replacement` that will be offered as a suggestion.
3636
/// { path = "std::sync::Mutex", reason = "prefer faster & simpler non-poisonable mutex", replacement = "parking_lot::Mutex" },
37+
/// # This would normally error if the path is incorrect, but with `allow-invalid` = `true`,
38+
/// # it will be silently ignored
39+
/// { path = "std::invalid::Type", reason = "use alternative instead", allow-invalid = true }
3740
/// ]
3841
/// ```
3942
///

0 commit comments

Comments
 (0)