rust/tests/ui-internal
llogiq 17f2a87c0c
Add internal lint derive_deserialize_allowing_unknown (#14360)
Adds an internal lint to check for `#[derive(serde::Deserialize)]`
without
[`#[serde(deny_unknown_fields)]`](https://serde.rs/container-attrs.html#deny_unknown_fields).

Today, if you run Clippy with the following clippy.toml, Clippy will
produce a warning, but there will be no accompanying note:
```toml
# In the following configuration, "recommendation" should be "reason" or "replacement".
disallowed-macros = [
    { path = "std::panic", recommendation = "return a `std::result::Result::Error` instead" },
]
```
```sh
$ cargo clippy
    Checking a v0.1.0 (/home/smoelius/tmp/a)
warning: use of a disallowed macro `std::panic`
 --> src/lib.rs:2:5
  |
2 |     panic!();
  |     ^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
  = note: `#[warn(clippy::disallowed_macros)]` on by default
```
The underlying problem is: the enum that derives `serde::Deserialize`
([`DisallowedPathEnum`](81643e297c/clippy_config/src/types.rs (L47)))
does not have the attribute `#[serde(deny_unknown_fields)]`.

This lint identifies such problems by checking trait `impl`s. An
alternative I considered was to walk `clippy_config::conf::Conf`
directly. However, that would not catch the `DisallowedPathEnum` case
because it [is not used in `Conf`
directly](81643e297c/clippy_config/src/types.rs (L31)).

Just to be clear, no one asked for this. So I hope the maintainers do
not mind.

changelog: none
2025-05-13 15:36:57 +00:00
..
check_clippy_version_attribute.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
check_clippy_version_attribute.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
check_formulation.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
check_formulation.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
collapsible_span_lint_calls.fixed Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
collapsible_span_lint_calls.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
collapsible_span_lint_calls.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
custom_ice_message.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
custom_ice_message.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
default_lint.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
default_lint.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
derive_deserialize_allowing_unknown.rs Add internal lint derive_deserialize_allowing_unknown 2025-05-13 10:48:41 -04:00
derive_deserialize_allowing_unknown.stderr Add internal lint derive_deserialize_allowing_unknown 2025-05-13 10:48:41 -04:00
disallow_span_lint.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
disallow_span_lint.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
interning_literals.fixed Replace interning of string literals with preinterned symbols 2025-04-18 22:44:16 +00:00
interning_literals.rs Replace interning of string literals with preinterned symbols 2025-04-18 22:44:16 +00:00
interning_literals.stderr Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
interning_literals_unfixable.rs Replace interning of string literals with preinterned symbols 2025-04-18 22:44:16 +00:00
interning_literals_unfixable.stderr Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
invalid_msrv_attr_impl.fixed Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
invalid_msrv_attr_impl.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
invalid_msrv_attr_impl.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
lint_without_lint_pass.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
lint_without_lint_pass.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
outer_expn_data.fixed Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
outer_expn_data.rs Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
outer_expn_data.stderr Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
symbol_as_str.fixed Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
symbol_as_str.rs Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
symbol_as_str.stderr Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
symbol_as_str_unfixable.rs Replace some Symbol::as_str usage 2025-04-25 01:03:03 +00:00
symbol_as_str_unfixable.stderr Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
unnecessary_def_path.rs Move lookup_path and similar into clippy_utils::paths 2025-05-04 17:13:02 +00:00
unnecessary_def_path.stderr Replace str path utils with new PathLookup type 2025-05-04 15:26:37 +00:00