Commit Graph

333 Commits

Author SHA1 Message Date
Alex Macleod
f7aef635c1 Rework interior mutability detection 2024-04-18 17:33:39 +00:00
Philipp Krones
846f6e7e00
Merge remote-tracking branch 'upstream/master' into rustup 2024-04-18 17:29:59 +02: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
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
Jason Newcomb
ac7c6e5417 Don't allow derive macros to silence disallowed_macros for their own call. 2024-02-10 16:10:05 -05:00
Philipp Krones
f3b3d23416 Merge commit '60cb29c5e4f9772685c9873752196725c946a849' into clippyup 2024-02-08 20:24:42 +01:00
J-ZhengLi
46dd8263a0 rename conf option to allowed_wildcard_imports 2024-02-02 09:22:42 +08:00
J-ZhengLi
314bddee95 add more test cases & improve docs & replace Vec with FxHashSet for segments 2024-01-30 09:38:14 +08:00
J-ZhengLi
d02df12bd5 add configuration for [wildcard_imports] to ignore certain imports 2024-01-30 09:38:14 +08:00
bors
855aa08de5 Auto merge of #12178 - mdm:modulo-arithmetic-comparison-to-zero, r=llogiq
Don't warn about modulo arithmetic when comparing to zero

closes #12006

By default, don't warn about modulo arithmetic when comparing to zero. This behavior is configurable via `clippy.toml`.

See discussion [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.E2.9C.94.20Is.20issue.20.2312006.20worth.20implementing.3F)

changelog: [`modulo_arithmetic`]: By default don't lint when comparing the result of a modulo operation to zero.
2024-01-27 12:22:48 +00:00
bors
8de9d8ce99 Auto merge of #12160 - GuillaumeGomez:incompatible-msrv, r=blyxyas
Warn if an item coming from more recent version than MSRV is used

Part of https://github.com/rust-lang/rust-clippy/issues/6324.

~~Currently, the lint is not working for the simple reason that the `stable` attribute is not kept in dependencies. I'll send a PR to rustc to see if they'd be okay with keeping it.~~

EDIT: There was actually a `lookup_stability` function providing this information, so all good now!

cc `@epage`

changelog: create new [`incompatible_msrv`] lint
2024-01-26 13:15:29 +00:00
Guillaume Gomez
14e15206ed Warn if an item coming from more recent version than MSRV is used 2024-01-26 14:13:02 +01:00
Philipp Krones
798865c593 Merge commit '66c29b973b3b10278bd39f4e26b08522a379c2c9' into clippy-subtree-update 2024-01-25 19:17:36 +01:00
Philipp Krones
1534e08250
Merge remote-tracking branch 'upstream/master' into rustup 2024-01-25 18:39:39 +01:00
Marc Dominik Migge
e456c28e11 Don't warn about modulo arithmetic when comparing to zero
Add lint configuration for `modulo_arithmetic`

Collect meta-data
2024-01-25 12:42:53 +01:00
y21
4780637cbc
suggest similar config option if one is found 2024-01-25 00:11:43 +01:00
y21
95a084f2eb [multiple_crate_versions]: add a configuration option for allowed duplicate dependencies 2024-01-21 03:23:41 +01:00
blyxyas
44f5d969d5
Change PublicallyExported -> PubliclyExported 2024-01-14 01:14:05 +01:00
Philipp Krones
aa220c7ee7 Merge commit '26ac6aab023393c94edf42f38f6ad31196009643' 2024-01-11 17:27:03 +01:00
Parker Timmerman
fa7dd1c4e0
add new lint, pub_underscore_fields
- add a new late pass lint, with config options
- add ui tests for both variations of config option
- update CHANGELOG.md

github feedback

bump version to 1.77 and run cargo collect-metadata

Change `,` to `;` in `conf.rs`
2023-12-29 11:44:34 +01:00
Philipp Krones
15b1edb209 Merge commit 'ac4c2094a6030530661bee3876e0228ddfeb6b8b' into clippy-subtree-sync 2023-12-28 19:33:07 +01:00
cocodery
18eb406776 Add test for indexing_slicing_index and modify related test 2023-12-22 20:31:48 +08:00
Philipp Krones
3596d44988 Merge commit 'a859e5cc1ce100df22346a1005da30532d04de59' into clippyup 2023-12-16 14:12:50 +01:00
bors
75bdbfcea5 Auto merge of #11853 - J-ZhengLi:issue11814, r=llogiq
expending lint [`blocks_in_if_conditions`] to check match expr as well

closes: #11814

changelog: rename lint `blocks_in_if_conditions` to [`blocks_in_conditions`] and expand it to check blocks in match scrutinees
2023-12-02 14:03:46 +00:00
Philipp Krones
c9a43b18f1 Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-sync 2023-12-01 18:21:58 +01:00
Philipp Krones
a9867e1847
Merge remote-tracking branch 'upstream/master' into rustup 2023-12-01 18:06:03 +01:00
J-ZhengLi
40b558af76 rename [blocks_in_if_conditions] to [blocks_in_conditions];
add more test cases with `match`;
minor fixes in message output regarding review feedback
2023-11-30 15:41:54 +08:00