Commit Graph

356 Commits

Author SHA1 Message Date
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
Oli Scherer 3b390d416d Bump clippy version 2024-07-15 08:51:04 +00:00
bors 8d3b1f9e30 Auto merge of #12984 - bitfield:fix_doc_nits_c, r=Alexendoo
Fix doc nits

More tender love and polish for the documentation and suggestion texts: adding formatting, links, full stops, tweaking wording for readability, changing 'which' to 'that' where appropriate, and other standard copyediting changes.

changelog: Docs [ `await_holding_lock` ]: fix doc nits
changelog: Docs [ `await_holding_refcell_ref` ]: fix doc nits
changelog: Docs [ `await_holding_invalid_type` ]: fix doc nits
changelog: Docs [ `cast_precision_loss` ]: fix doc nits
changelog: Docs [ `cast_sign_loss` ]: fix doc nits
changelog: Docs [ `cast_possible_truncation` ]: fix doc nits
changelog: Docs [ `cast_possible_wrap` ]: fix doc nits
changelog: Docs [ `cast_lossless` ]: fix doc nits
changelog: Docs [ `unnecessary_cast` ]: fix doc nits
changelog: Docs [ `cast_ptr_alignment` ]: fix doc nits
changelog: Docs [ `fn_to_numeric_cast` ]: fix doc nits
changelog: Docs [ `fn_to_numeric_cast_with_truncation` ]: fix doc nits
changelog: Docs [ `fn_to_numeric_cast_any` ]: fix doc nits
changelog: Docs [ `char_lit_as_u8` ]: fix doc nits
changelog: Docs [ `ptr_as_ptr` ]: fix doc nits
changelog: Docs [ `ptr_cast_constness` ]: fix doc nits
changelog: Docs [ `as_ptr_cast_mut` ]: fix doc nits
changelog: Docs [ `little_endian_bytes` ]: fix doc nits
changelog: Docs [ `big_endian_bytes` ]: fix doc nits
changelog: Docs [ `bind_instead_of_map` ]: fix doc nits
changelog: Docs [ `same_name_method` ]: fix doc nits
2024-07-10 17:55:08 +00: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 2da0edbdf1
Honor avoid-breaking-exported-api in needless_pass_by_ref_mut
Until now, the lint only emitted a warning, when breaking public API. Now it
doesn't lint at all when the config value is not set to `false`, bringing it in
line with the other lints using this config value.

Also ensures that this config value is documented in the lint.
2024-07-02 19:30:01 +02:00
xFrednet 3bbec6aade `sudo CI=green` && Review changes <3 2024-06-25 18:06:22 +02:00
xFrednet 1b4c281fe7 RFC 2383: Stabilize `lint_reasons` in Clippy 🖇️ 2024-06-25 17:50:48 +02:00
John Arundel 625091d236 Fix doc nits 2024-06-23 13:11:54 +01:00
Trevor Gross c693f31ee2 Update float tests to include `f16` and `f128` 2024-06-19 13:30:21 -04:00
Philipp Krones 3bff119f63 Merge commit '3e5a02b13b1244545454752c6629b767522a44b1' into clippy-subtree-update 2024-06-13 12:30:48 +02:00
bors 6cfd4ac955 Auto merge of #10632 - Alexendoo:needless-maybe-sized, r=Jarcho
Add `needless_maybe_sized` lint

changelog: new lint: [`needless_maybe_sized`]

Closes #10600
2024-06-05 20:11:03 +00:00
Paul R. Tagliamonte 35e2027a35 Fix grammer for the Safety documentation check
The original message ("unsafe function's docs miss `# Safety` section")
reads quite awkwardly. I've changed it to "unsafe function's docs are missing
a `# Safety` section" to have it read better.

Signed-off-by: Paul R. Tagliamonte <paultag@gmail.com>
2024-06-05 14:11:56 -04:00
Daniel Sedlak c342a61564 Add configuration option for ignoring `panic!()` in tests 2024-05-16 05:45:56 +00:00
y21 9747c80644 new lint: `macro_metavars_in_unsafe` 2024-05-12 17:03:30 +02:00
J-ZhengLi 46659acdbd add configuration to allow skipping on some certain traits & collect metadata 2024-05-12 22:13:17 +08:00
Rebecca Turner 8d8c0bfb0e
useless_attribute: allow clippy::disallowed_types
Closes https://github.com/rust-lang/rust-clippy/issues/12753
2024-05-02 11:55:11 -07:00
Philipp Krones e8492355a3
Merge remote-tracking branch 'upstream/master' into rustup 2024-05-02 14:21:00 +02:00
Andre Bogus 87efce4fa2 configurably allow `useless_vec` in tests
This adds a `àllow-useless-vec-in-test` configuration which, when set
to `true` will allow the `useless_vec` lint in `#[test]` functions and
code within `#[cfg(test)]`. It also moves a `is_in_test` helper to
`clippy_utils`.
2024-04-28 22:07:56 +02:00
Gary Guo 7d9f970d4e Fix and bless clippy tests 2024-04-24 13:12:33 +01:00
Alex Macleod f7aef635c1 Rework interior mutability detection 2024-04-18 17:33:39 +00: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
Alex Macleod cf0b55eb62 Add `needless_maybe_sized` lint 2024-04-14 14:43:03 +00:00
bors 832fdb6d30 Auto merge of #12573 - modelflat:recognize-common-prepositions-in-module-name-repetitions, r=Jarcho
[`module_name_repetition`] Recognize common prepositions

Fixes #12544

changelog: [`module_name_repetition`]: don't report an item name if it consists only of a prefix from `allowed-prefixes` list and a module name (e.g. `AsFoo` in module `foo`). Prefixes allowed by default: [`to`, `from`, `into`, `as`, `try_into`, `try_from`]
2024-04-12 18:53:03 +00:00
Matthias Krüger 2e989dc280 Rollup merge of #123204 - notriddle:notriddle/include-str-span, r=pnkfelix
rustdoc: point at span in `include_str!`-ed md file

Fixes #118549
2024-04-12 17:41:32 +02:00
modelflat 3705073a71 Recognize common prefixes when checking for items with module name suffix
Fixes #12544.

- don't report an item name if it consists only of a prefix from `allowed-prefixes` list and a module name (e.g. `AsFoo` in module `foo`).
- configured by `allowed-prefixes` config entry
- prefixes allowed by default: [`to`, `from`, `into`, `as`, `try_into`, `try_from`]
- update docs
2024-04-09 09:47:54 +02:00
Philipp Krones 0ae4a048c6 Merge commit '9725c4a162502a02c1c67fdca6b797fe09b2b73c' into clippy-subtree-update 2024-04-04 19:52:55 +02:00
Philipp Krones 277303b210
Merge remote-tracking branch 'upstream/master' into rustup 2024-04-04 19:48:31 +02:00
bors cebf879de8 Auto merge of #12312 - pitaj:legacy_numeric_constants, r=xFrednet
new lint `legacy_numeric_constants`

Rework of #10997

- uses diagnostic items
- does not lint imports of the float modules (`use std::f32`)
- does not lint usage of float constants that look like `f32::MIN`

I chose to make the float changes because the following pattern is actually pretty useful
```rust
use std::f32;
let omega = freq * 2 * f32::consts::PI;
```
and the float modules are not TBD-deprecated like the integer modules.

Closes #10995

---

changelog: New lint [`legacy_numeric_constants`]
[#12312](https://github.com/rust-lang/rust-clippy/pull/12312)
2024-03-30 17:50:36 +00:00
Michael Howell 24e1071d21 clippy: fix up `include_str!` spans in diagnostics 2024-03-29 13:34:01 -07:00
Kevin Reid 01646457a9 `large_stack_frames`: print total size and largest component.
Instead of just saying “this function's stack frame is big”, report:

* the (presumed) size of the frame
* the size and type of the largest local contributing to that size
* the configurable limit that was exceeded (once)
2024-03-28 11:00:42 -07:00
bors e5ece90f64 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin
Replace visibility test with reachability test in dead code detection

Fixes https://github.com/rust-lang/rust/issues/119545

Also included is a fix for an error now flagged by the lint
2024-03-23 00:37:05 +00:00
Catherine 0c392d918a new lint `legacy_numeric_constants` 2024-03-21 17:10:02 -06:00
Philipp Krones 0e62b18435 Merge commit '9d6f41691ed9dbfaec2a2df2661c42451f2fe0d3' into clippy-subtree-update 2024-03-21 22:20:40 +01:00
J-ZhengLi 0535f55831 lint nested `dbg!` macros, split tests 2024-03-14 09:29:29 +08:00
Arthur Carcano cbbb0ae7d2 fix: allow-one-hash-in-raw-strings option of needless_raw_string_hashes was ignored
Fixes: https://github.com/rust-lang/rust-clippy/issues/11481

changelog: Fix `allow-one-hash-in-raw-strings` option of [`needless_raw_string_hashes`] was ignored
2024-03-12 10:59:41 +01:00
Philipp Krones 7e83df4068 Merge commit '93f0a9a91f58c9b2153868f458402155fb6265bb' into clippy-subtree-update 2024-03-07 17:19:29 +01:00
Philipp Krones a6df0277ea
Merge remote-tracking branch 'upstream/master' into rustup 2024-03-07 17:14:36 +01:00
Philipp Krones 7be6e2178e Merge commit '10136170fe9ed01e46aeb4f4479175b79eb0e3c7' into clippy-subtree-update 2024-02-27 15:50:17 +01:00
bors b8fb8907ba Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
Implement RFC 3373: Avoid non-local definitions in functions

This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-25 19:11:06 +00:00
Philipp Krones dc0bb69e66
Merge remote-tracking branch 'upstream/master' into rustup 2024-02-22 15:59:29 +01:00
Philipp Krones 4363278c73 Merge commit '2efebd2f0c03dabbe5c3ad7b4ebfbd99238d1fb2' into clippy-subtree-update 2024-05-21 10:39:30 -07:00
Philipp Krones 80c6f8ff7b Merge commit '20b085d500dfba5afe0869707bf357af3afe20be' into clippy-subtree-update 2024-05-02 17:26:44 +02:00
Oli Scherer d136b05c1b Always evaluate free constants and statics, even if previous errors occurred 2024-02-19 22:11:13 +00:00
bors 74f611f7fc Auto merge of #12306 - Alexendoo:dir-replacement, r=flip1995
Remove `$DIR` replacement

This won't cause problems because the old `$DIR` replacement was based on the parent of the test path, which for us is relative: 5471e0645a/tests/compile-test.rs (L122)

The new pattern being `"tests/{test_dir}"` is more clearly relative

That's why we have custom filters applied to the toml/cargo tests where absolute paths do appear in the output 5471e0645a/tests/compile-test.rs (L198-L202)

Removing it allows clicking the paths in the terminal

changelog: none

r? `@flip1995`
2024-02-19 09:20:07 +00:00
Victor Song d1e8a5956f fix: make `#[allow]` work on field for `pub_underscore_fields`
Add test for future regression
2024-02-18 05:33:50 -06:00
Urgau 4d93edf346 Allow newly added non_local_definitions lint in clippy 2024-02-17 13:59:45 +01:00
Alex Macleod 1d107ab2be Remove $DIR replacement in test output 2024-02-17 12:34:54 +00:00
Oli Scherer c975c5f69e Bump ui_test version 2024-02-16 21:40:43 +01:00
Ethiraric c1c2c3e60c Ignore imported items in `min_ident_chars`
Suppress the `min_ident_chars` warning for items whose name we cannot
control. Do not warn for `use a::b`, but warn for `use a::b as c`, since
`c` is a local identifier.

Fixes #12232
2024-02-13 19:14:12 +01:00