Samuel Tardieu
82381608c9
Lint more cases in collapsible_if
...
Replace the use of `Sugg::ast()` which prevented combining `if`
together when they contained comments by span manipulation.
A new configuration option `lint_commented_code`, which is `true` by
default, opts out from this behavior.
2025-03-22 15:12:42 +01:00
Philipp Krones
02e812af4d
Merge remote-tracking branch 'upstream/master' into rustup
2025-02-27 21:51:42 +01:00
Alejandra González
b583568e72
Add unnecessary_debug_formatting lint ( #13893 )
...
Fixes #12674 , i.e., adds a lint to flag `Path`s printed with `{:?}`.
Nits are welcome.
changelog: Add `unnecessary_debug_formatting` lint
2025-02-26 15:03:57 +00:00
Samuel Moelius
6af901c51e
Add unnecessary_debug_formatting lint
...
Address review comments
Fix adjacent code
Required now that the lint is pedantic
Add inline formatting tests
Add note re formatting changes
Address `unnecessary_map_or` warnings
Address additional review comments
Typo
Update Clippy version
2025-02-26 14:25:58 +00:00
Jana Dönszelmann
443b0f5ccf
Fix rustdoc and clippy
2025-02-24 14:31:19 +01:00
Manish Goregaokar
35d5ee0e41
add MSRV check for repeat_vec_with_capacity ( #14126 )
...
changelog: [`repeat_vec_with_capacity`]: add MSRV check
2025-02-23 15:50:44 +00:00
Philipp Krones
12025085b9
Merge remote-tracking branch 'upstream/master' into rustup
2025-02-20 15:26:07 +01:00
cyrgani
758ec1d332
remove an unneeded #![feature]
2025-02-18 11:04:53 +01:00
llogiq
c3239baed0
Add single_option_map lint ( #14033 )
...
Checks for functions with method calls to `.map(_)` on an arg of type
`Option` as the outermost expression.
Fixes #774
```
changelog: [`single_option_map`]: Checks for functions with method calls to `.map(_)` on an arg of type `Option` as the outermost expression.
```
2025-02-09 21:57:59 +00:00
Yusuf Raji
4d4ef0000c
Add single_option_map lint
2025-02-09 22:53:10 +01:00
Guillaume Gomez
24ea8a55d1
Convert EMPTY_LINE_AFTER_OUTER_ATTR and EMPTY_LINE_AFTER_OUTER_ATTR lint into early lints
2025-02-07 16:47:24 +01:00
Catherine Flores
b0ad06daa8
add MSRV check for lines_filter_map_ok ( #14130 )
...
fixes #14127
changelog: [`lines_filter_map_ok`]: respect MSRV
2025-02-07 12:24:50 +00:00
Philipp Krones
5aa9d7ae7f
Merge commit ' 3e3715c312' into clippy-subtree-update
2025-02-06 15:00:24 +01:00
lapla-cogito
f9669e4caf
add MSRV check for lines_filter_map_ok
2025-02-01 15:20:34 +09:00
lapla-cogito
2a52fbe5da
add MSRV check for repeat_vec_with_capacity
2025-02-01 12:42:39 +09:00
Philipp Krones
9da9ddb7db
Merge commit ' 51d49c1ae2' into clippy-subtree-update
2025-01-28 19:33:54 +01:00
Andre Bogus
13be95ab11
new manual_option_as_slice lint
2025-01-26 21:27:44 +01:00
J-ZhengLi
2671e4a5c1
add new lint non_std_lazy_statics
...
detect usage of `once_cell::sync::Lazy` and `lazy_static!`,
recommending usage of `std::sync::LazyLock` instead
2025-01-24 14:06:46 -07:00
Samuel Tardieu
9dca770aec
unnecessary_semicolon: do not lint if it may cause borrow errors
...
Before edition 2024, some temporaries used in scrutinees in a `match`
used as the last expression of a block may outlive some referenced
local variables. Prevent those cases from happening by checking that
alive temporaries with significant drop do have a static lifetime.
The check is performed only for edition 2021 and earlier, and for the
last statement if it would become the last expression of the block.
2025-01-22 13:40:26 +01:00
Samuel Tardieu
51b0107d28
New lint: unnecessary_semicolon
2025-01-19 15:34:07 +01:00
Samuel Tardieu
8b7cfc75dd
Rust 1.81 and later support elision with explicit self types
...
Commit 9ef6e2199c introduced a check to
ensure that Clippy doesn't consider a lifetime present in an explicit
self type as being the default for an elided output lifetime. For
example, elision did not work in the case like:
```rust
fn func(self: &Rc<Self>, &str) -> &str { … }
```
Since Rust 1.81.0, the lifetime in the self type is now considered
the default for elision. Elision should then be suggested when
appropriate.
2025-01-13 23:34:19 +01:00
Catherine Flores
34d109fd26
Add new lint unneeded_struct_pattern ( #13465 )
...
Closes #13400 .
changelog: [`unneeded_struct_pattern`]: Add new lint
2025-01-12 02:09:18 +00:00
Philipp Krones
d0a74af979
Merge commit ' 19e305bb57' into clippy-subtree-update
2025-01-09 18:57:00 +01:00
Timo
a8968e5dd8
Make inconsistent_struct_constructor "all fields are shorthand" requirement configurable ( #13737 )
...
Fixes #11846 .
This PR has three commits:
- The first commit adds an `initializer-suggestions` configuration to
control suggestion applicability when initializers are present. The
following are the options:
- "none": do not suggest
- "maybe-incorrect": suggest, but do not apply suggestions with `--fix`
- "machine-applicable": suggest and apply suggestions with `--fix`
- The second commit fixes suggestions to handle field attributes
(problem [noticed by
@samueltardieu](https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1859261645 )).
- The third commit adds `initializer-suggestions = "machine-applicable"`
to Clippy's `clippy.toml` and applies the suggestions. (Nothing seems to
break.)
---
changelog: make `inconsistent_struct_constructor` "all fields are
shorthand" requirement configurable
2024-12-27 22:05:03 +00:00
Samuel Moelius
8a38bcc390
Make "all fields are shorthand" requirement configurable
...
Handle field attributes in suggestions
Fix adjacent code
Address review comments
https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1861352124
Address all review comments but one
This comment is not yet addressed: https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1874544907
`initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
2024-12-26 19:36:58 -05:00
Philipp Krones
1cc50519d1
Merge commit ' 609cd310be' 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
Jonathan Dönszelmann
4d05825f3e
rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures
2024-12-16 19:08:19 +01:00
Guillaume Gomez
ad695da7d2
Correctly handle string indices in literal_string_with_formatting_arg
2024-12-16 17:06:22 +01:00
Philipp Krones
12edfb82e5
Merge remote-tracking branch 'upstream/master' into rustup
2024-12-15 16:48:56 +01:00
Asuna
52abb8f9f0
Add new lint unneeded_struct_pattern
2024-12-15 03:59:11 +01:00
Urgau
c8d800e288
Drop uplifted clippy::fn_address_comparisons
2024-12-02 18:43:37 +01:00
Guillaume Gomez
cfc6444f84
Limit literal_string_with_formatting_args to known variables if no formatting argument is passed
2024-11-22 14:58:59 +01:00
Guillaume Gomez
607a3f6c08
Rename literal_string_with_formatting_arg into literal_string_with_formatting_args
2024-11-22 14:57:20 +01:00
Guillaume Gomez
8d5a4e95e3
Allow literal_string_with_formatting_arg in some clippy crates
2024-11-22 14:57:20 +01:00
Guillaume Gomez
cd7cec9066
Add new literal_string_with_formatting_arg lint
2024-11-19 15:44:19 +01:00
Philipp Krones
6ced8c33c0
Merge commit ' f712eb5cdc' into clippy-subtree-update
2024-11-07 22:37:01 +01:00
Philipp Krones
f712eb5cdc
Merge pull request #13657 from jdonszelmann/disallowed-macros-to-early
...
collect attribute spans early for disallowed macros
2024-11-07 19:23:20 +00:00
Philipp Krones
b816d4ee4f
Merge remote-tracking branch 'upstream/master' into rustup
2024-11-07 17:22:32 +01:00
Jonathan Dönszelmann
c93109674f
collect attribute spans early for disallowed macros
2024-11-05 20:46:44 +01:00
Jonathan Dönszelmann
63d0ba9de9
Move two attribute lints to be early pass (post expansion)
2024-11-04 22:47:22 +01:00
decryphe
f7ab2c9908
new lint: source_item_ordering
2024-10-30 10:03:16 +01:00
blyxyas
e518d66dc0
Apply review comments + use shallow_lint_levels_on
2024-10-19 16:20:52 +02:00
blyxyas
e427a4e694
Remove module passes filtering
2024-10-19 16:20:51 +02:00
blyxyas
8f8aa46a87
Follow review comments (optimize the filtering)
2024-10-19 16:20:33 +02:00
bors
f2f0175eb2
Auto merge of #13543 - GnomedDev:symbol-comparisons, r=y21
...
Add internal lint to check for slow symbol comparisons
See the conversation on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Checking.20a.20Symbol.20is.20equal.20to.20a.20string.20literal ).
changelog: none
2024-10-18 23:20:38 +00:00
Philipp Krones
fea5e77da1
Merge commit ' a109190d70' into clippy-subtree-update
2024-10-18 13:44:06 +02:00
Philipp Krones
224d1e323a
Merge remote-tracking branch 'upstream/master' into rustup
2024-10-18 13:25:37 +02:00
GnomedDev
42511a3ffa
Add lint for unnecessary lifetime bounded &str return
2024-10-15 17:06:21 +01:00
GnomedDev
6b1779b0ee
Add lint to check for slow symbol comparisons
2024-10-13 16:36:22 +01:00