diff options
| author | llogiq <bogusandre@gmail.com> | 2025-05-13 15:36:57 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-13 15:36:57 +0000 |
| commit | 17f2a87c0cdade23b20ea5b3004235d8c1db8eb5 (patch) | |
| tree | ad52c802a48b6707b92d83b5085989d73119fd97 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 7bac114c8645d40291502c0d8028ffd16c7e8c01 (diff) | |
| parent | 9f4ecea24269f6a6c7cd54b4648a1ccd23a58d90 (diff) | |
| download | rust-17f2a87c0cdade23b20ea5b3004235d8c1db8eb5.tar.gz rust-17f2a87c0cdade23b20ea5b3004235d8c1db8eb5.zip | |
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`](https://github.com/rust-lang/rust-clippy/blob/81643e297cf44ce3c7648b8443fc4d6592fa81eb/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](https://github.com/rust-lang/rust-clippy/blob/81643e297cf44ce3c7648b8443fc4d6592fa81eb/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
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
