Commit Graph

116 Commits

Author SHA1 Message Date
Samuel Moelius 7f125af963 Commas to semicolons in clippy.toml reasons 2025-08-30 12:15:36 -04:00
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`](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
2025-05-13 15:36:57 +00:00
Samuel Moelius 9f4ecea242 Add internal lint derive_deserialize_allowing_unknown 2025-05-13 10:48:41 -04:00
Alex Macleod 5aac708398 Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
Alex Macleod f23772ce8c Move lookup_path and similar into clippy_utils::paths 2025-05-04 17:13:02 +00:00
Alex Macleod b768fbe4bc Replace str path utils with new PathLookup type 2025-05-04 15:26:37 +00:00
Alex Macleod 7b337f6e25 Replace some Symbol::as_str usage 2025-04-25 01:03:03 +00:00
Alex Macleod b52bd96713 Replace interning of string literals with preinterned symbols 2025-04-18 22:44:16 +00:00
Jason Newcomb 5b4b463d49 Move internal lints to their own crate 2025-04-12 17:53:36 -04:00
Guillaume Gomez ec8c0b3755 Make annotations mandatory for internal ui tests 2025-03-12 11:32:40 +01:00
Guillaume Gomez cb9682b628 Add missing tests annotations for ui-internal 2025-03-11 16:35:11 +01:00
Alex Macleod 5b0004c45f Migrate clippy_lints to new MSRV API 2025-02-28 18:15:11 +00:00
Alex Macleod 0972c3b565 Check for MSRV attributes in late passes using the HIR 2025-02-28 18:09:44 +00:00
Philipp Krones 02e812af4d Merge remote-tracking branch 'upstream/master' into rustup 2025-02-27 21:51:42 +01:00
Philipp Krones 12025085b9 Merge remote-tracking branch 'upstream/master' into rustup 2025-02-20 15:26:07 +01:00
Philipp Krones 9da9ddb7db Merge commit '51d49c1ae2785b24ef18a46ef233fc1d91844666' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
Philipp Krones 145d5adf04 Merge remote-tracking branch 'upstream/master' into rustup 2025-01-28 19:14:45 +01:00
Philipp Krones d0a74af979 Merge commit '19e305bb57a7595f2a8d81f521c0dd8bf854e739' into clippy-subtree-update 2025-01-09 18:57:00 +01:00
Philipp Krones b5bf09e57a Merge remote-tracking branch 'upstream/master' into rustup 2025-01-09 18:00:37 +01:00
Philipp Krones 1cc50519d1 Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into clippy-subtree-update 2024-12-26 15:15:54 +01:00
Philipp Krones 14af404672 Merge remote-tracking branch 'upstream/master' into rustup 2024-12-26 14:46:57 +01:00
Philipp Krones d58b911e01 Merge commit 'ff4a26d442bead94a4c96fb1de967374bc4fbd8e' into clippy-subtree-update 2024-11-28 19:38:59 +01:00
Philipp Krones 5c1811ab94 Rename all clippy_config::msrvs -> clippy_utils::msrvs 2024-11-15 19:38:09 +01:00
Philipp Krones 1ceaa90413 Merge commit '786fbd6d683933cd0e567fdcd25d449a69b4320c' into clippy-subtree-update 2024-11-14 19:35:26 +01:00
Jacherr 89210d7c5a new lint unnecessary_map_or 2024-11-12 23:00:26 +00:00
Philipp Krones 6ced8c33c0 Merge commit 'f712eb5cdccd121d0569af12f20e6a0fabe4364d' into clippy-subtree-update 2024-11-07 22:37:01 +01:00
Philipp Krones c64f1e3591 Fix lint_without_lint_pass internal lint 2024-11-07 17:27:46 +01:00
Philipp Krones 03daf7ccb2 Fix author lint and move it back to tests/ui
The author lint is not an internal lint, and should also be enabled, when Clippy
is distributed through rustup. This moves the author lint test cases back to
tests/ui.
2024-11-07 17:22:32 +01:00
Philipp Krones b816d4ee4f Merge remote-tracking branch 'upstream/master' into rustup 2024-11-07 17:22:32 +01:00
blyxyas 698363122e Do not run lints that cannot emit
Before this change, adding a lint was a difficult matter
because it always had some overhead involved. This was
because all lints would run, no matter their default level,
or if the user had #![allow]ed them. This PR changes that
2024-10-19 16:19:44 +02:00
GnomedDev a650692f8d Add test 2024-10-13 21:03:39 +01:00
GnomedDev dedc380df9 Apply fixes from lint 2024-10-13 21:03:38 +01:00
Philipp Krones b61fcbee76 Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into clippy-subtree-update 2024-09-24 11:58:04 +02:00
Philipp Krones 3ab1da8bab Formatting 2024-09-22 20:52:15 +02:00
Philipp Krones d140e26cc0 Merge remote-tracking branch 'upstream/master' into rustup 2024-09-22 20:51:17 +02:00
Philipp Krones 1ac76a2062 Merge commit 'cb806113e0f83a8f9b47d35b453b676543bcc40e' into clippy-subtree-update 2024-08-08 19:13:50 +02:00
Jason Newcomb 2c34d58159 Store deprecated lints as an array of tuples.
Remove legacy deprecations.
Remove "View Source" link for deprecated lints.
2024-08-05 09:15:55 -04:00
Philipp Krones 4e6851e50b Merge commit '37f4fbb92913586b73a35772efd00eccd1cbbe13' into clippy-subtree-update 2024-07-25 18:29:17 +02:00
Jason Newcomb e34c6dbae5 Refactor for using config values:
* Construct lint passes by taking `Conf` by reference.
* Use `HashSet` configs in less places
* Move some `check_crate` code into the pass constructor when possible.
2024-07-17 14:05:49 -04:00
Philipp Krones c1fd25d0aa Merge commit 'b794b8e08c16517a941dc598bb1483e8e12a8592' into clippy-subtree-update 2024-07-11 15:44:03 +02:00
Jason Newcomb 60af2585f7 Refactor disallowed_methods:
* Simplify `def_id` extraction.
* Use the span of the method name instead of the call.
2024-07-05 02:37:09 -04:00
Philipp Krones f67f72695a Merge commit 'c9139bd546d9cd69df817faeab62c5f9b1a51337' into clippy-subtree-update 2024-05-30 10:49:05 +02:00
Philipp Krones 89037ea18f Merge remote-tracking branch 'upstream/master' into rustup 2024-05-30 09:44:14 +02:00
León Orell Valerian Liehr 0c653d9f91 Remove LintDiagnostic::msg
* instead simply set the primary message inside the lint decorator functions
* it used to be this way before [#]101986 which introduced `msg` to prevent
  good path delayed bugs (which no longer exist) from firing under certain
  circumstances when lints were suppressed / silenced
* this is no longer necessary for various reasons I presume
* it shaves off complexity and makes further changes easier to implement
2024-05-23 04:08:35 +02:00
Philipp Krones a5aaf33422 Merge commit 'ca3b393750ee8d870bf3215dcf6509cafa5c0445' into clippy-subtree-update 2024-04-18 17:48:52 +02:00
Philipp Krones 846f6e7e00 Merge remote-tracking branch 'upstream/master' into rustup 2024-04-18 17:29:59 +02:00
Matthias Krüger 4daaf19138 Rollup merge of #122807 - danielhuang:fix-1, r=davidtwco
Add consistency with phrases "meantime" and "mean time"

"mean time" is used in a few places while "meantime" is used everywhere else; this would make usage consistent throughout the codebase.
2024-04-08 14:31:10 +02:00
Dan ca92c0a7a4 update messages 2024-04-03 19:03:12 -04:00
Philipp Krones 0e62b18435 Merge commit '9d6f41691ed9dbfaec2a2df2661c42451f2fe0d3' into clippy-subtree-update 2024-03-21 22:20:40 +01:00
y21 eb5ce85932 mention span_lint_hir in span_lint and add a reason to disallowed_methods 2024-03-09 19:40:39 +01:00