Commit Graph

8740 Commits

Author SHA1 Message Date
Lzu Tao
dcee2e8a0f Dont stop find loop node at struct field node 2024-07-15 15:56:17 +00:00
Lzu Tao
4264548283 Add regression test for issue 13077 2024-07-15 15:55:22 +00:00
bors
c4125286ce Auto merge of #12840 - tesuji:const-asserts, r=llogiq
Don't lint `assertions_on_constants` on any const assertions

close #12816
close #12847
cc #12817

----

changelog: Fix false positives in consts for `assertions_on_constants` and `unnecessary_operation`.
2024-07-01 22:06:06 +00:00
Roman Franchuk
b08b8b8a75 Implement a lint to replace bit manual rotations with rotate_left/rotate_right 2024-06-29 22:31:10 +02:00
bors
1aa236d59b Auto merge of #13006 - flip1995:manual-inspect-error-message, r=Jarcho
Add error message to manual_inspect lint

r? `@Jarcho`

changelog: none
2024-06-28 18:47:12 +00:00
Philipp Krones
01a6dfa29f
Add error message to manual_inspect lint 2024-06-28 10:29:18 +02:00
Michael Howell
6de87829da doc_lazy_continuation: blank comment line for gap
This change addresses cases where doc comments are separated
by blank lines, comments, or non-doc-comment attributes,
like this:

```rust
/// - first line
// not part of doc comment
/// second line
```

Before this commit, Clippy gave a pedantically-correct
warning about how you needed to indent the second line.
This is unlikely to be what the user intends, and has
been described as a "false positive" (since Clippy is
warning you about a highly unintuitive behavior that
Rustdoc actually has, we definitely want it to output
*something*, but the suggestion to indent was poor).

https://github.com/rust-lang/rust-clippy/issues/12917
2024-06-27 17:09:54 -07:00
Philipp Krones
e9e7a815a7
Merge remote-tracking branch 'upstream/master' into rustup 2024-06-27 18:49:59 +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
Vadim Petrochenkov
8c718e5524 ast: Standardize visiting order for attributes and node IDs 2024-06-24 16:08:51 +03:00
bors
32374a196d Auto merge of #12930 - DaniPopes:missing-const-for-fn-suggestion, r=Jarcho
[`missing_const_for_fn`]: add machine-applicable suggestion

Add a machine-applicable suggestion to the `missing_const_for_fn` lint.

changelog: [`missing_const_for_fn`]: add machine-applicable suggestion
2024-06-23 20:04:27 +00:00
Andre Bogus
51ccad6986
use short message format in integration test 2024-06-23 17:20:07 +02:00
Guillaume Gomez
58fc27f571 Rollup merge of #126723 - estebank:dot-dot-dot, r=Nadrieril
Fix `...` in multline code-skips in suggestions

When we have long code skips, we write `...` in the line number gutter.

For suggestions, we were "centering" the `...` with the line, but that was inconsistent with what we do in every other case *and* off-center.
2024-06-22 12:57:19 +02:00
bors
0ce07f61db Auto merge of #12961 - GuillaumeGomez:fix-manual_unwrap_or_default, r=Alexendoo
Fix incorrect suggestion for `manual_unwrap_or_default`

Fixes #12928.

If this not a "simple" pattern, better not emit the lint.

changelog: Fix incorrect suggestion for `manual_unwrap_or_default`
2024-06-21 17:05:43 +00:00
Guillaume Gomez
54b45f7f93 Fix incorrect suggestion for manual_unwrap_or_default 2024-06-21 18:18:28 +02:00
vohoanglong0107
2f9f204123 feat: unnecessary_min_max lint 2024-06-20 13:57:16 +00:00
Esteban Küber
3baafd2e8c Fix ... in multline code-skips in suggestions
When we have long code skips, we write `...` in the line number gutter.

For suggestions, we were "centering" the `...` with the line, but that was consistent with what we do in every other case.
2024-06-20 04:25:17 +00:00
Renato Lochetti
b147b6d03d
Don't lint implicit_return on proc macros 2024-06-19 19:16:09 +01:00
Trevor Gross
c693f31ee2 Update float tests to include f16 and f128 2024-06-19 13:30:21 -04:00
bors
9e54ff2952 Auto merge of #12906 - lochetti:manual_unwrap_or_if_let, r=y21
Lint `manual_unwrap_or` for it let cases

This PR modifies `manual_unwrap_or` to lint for `if let` cases as well. This effort is part of the fixes desired by https://github.com/rust-lang/rust-clippy/issues/12618

changelog:[`manual_unwrap_or`]: Lint for `if let` cases.
2024-06-17 21:21:56 +00:00
bors
51c5eee9e6 Auto merge of #12945 - Jarcho:octal_escape, r=Alexendoo
Rework `octal_escapes`

Main changes are not doing UTF-8 decoding, noting each occurrence as an individual lint emission, and narrowing the span to point to the escape itself.

changelog: none
2024-06-17 20:12:43 +00:00
bors
0625183e28 Auto merge of #12903 - Jarcho:issue_12284, r=y21
Fix ICE in `upper_case_acronyms`

fixes #12284

The logic has been rewritten to avoid allocations. The old version allocated multiple vecs and strings for each identifier. The new logic allocates a single string only when the lint triggers.

This also no longer lints on strings which don't start with an uppercase letter (e.g. `something_FOO`).

changelog: none
2024-06-17 15:45:38 +00:00
Jason Newcomb
4b16e265a7 Rework octal_escapes. 2024-06-16 22:36:24 -04:00
Jason Newcomb
22710f33a8 Add lint manual_inspect 2024-06-16 18:33:43 -04:00
kyle oneill
3405ce3bca Add field_scoped_visibility_modifiers lint 2024-06-16 15:54:48 -04:00
AurelienFT
51c6630d4f Change MSRV check for manual_pattern_char_comparison only for pattern arrays 2024-06-15 21:52:42 +02:00
AurelienFT
63388cbab8 add MSRV for manual_pattern_char_comparison 2024-06-15 21:45:35 +02:00
bors
0dc265ff82 Auto merge of #12756 - y21:assigning_clones_lifetimes, r=Alexendoo
Avoid emitting `assigning_clones` when cloned data borrows from the place to clone into

Fixes #12444
Fixes #12460
Fixes #12749
Fixes #12757
Fixes #12929

I think the documentation for the function should describe what- and how this is fixing the issues well.
It avoids emitting a warning when the data being cloned borrows from the place to clone into, which is information that we can get from `PossibleBorrowerMap`. Unfortunately, it is a tiny bit tedious to match on the MIR like that and I'm not sure if this is possibly relying a bit too much on the exact MIR lowering for assignments.

Things left to do:
- [x] Handle place projections (or verify that they work as expected)
- [x] Handle non-`Drop` types

changelog: [`assigning_clones`]: avoid warning when the suggestion would lead to a borrow-check error
2024-06-15 18:25:42 +00:00
DaniPopes
82f0dc95a0
[missing_const_for_fn]: add machine-applicable suggestion 2024-06-14 14:43:08 +02:00
Esteban Küber
fa9274c99b Tweak output of import suggestions
When both `std::` and `core::` items are available, only suggest the
`std::` ones. We ensure that in `no_std` crates we suggest `core::`
items.

Ensure that the list of items suggested to be imported are always in the
order of local crate items, `std`/`core` items and finally foreign crate
items.

Tweak wording of import suggestion: if there are multiple items but they
are all of the same kind, we use the kind name and not the generic "items".

Fix #83564.
2024-06-13 20:22:21 +00:00
bors
ba347f9815 Auto merge of #126398 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`

Updates `Cargo.lock` with Clippy version bump.
2024-06-13 16:17:56 +00:00
Philipp Krones
3bff119f63 Merge commit '3e5a02b13b1244545454752c6629b767522a44b1' into clippy-subtree-update 2024-06-13 12:30:48 +02:00
Waffle Lapkin
c3d463333f Fixup clippy tests
Don't depend on the fact that `!` falls back to `()` and so panic-ish things
can be used in `-> impl ImplementedForUnit` functions
2024-06-13 12:24:31 +02:00
Philipp Krones
cc63143bbf
Merge remote-tracking branch 'upstream/master' into rustup 2024-06-13 12:24:08 +02:00
bors
aaade2d12d Auto merge of #12855 - tesuji:fix-author-lint, r=Jarcho
Fix typos of author lint

changelog: none
2024-06-11 22:49:18 +00:00
bors
38d12a9bc0 Auto merge of #12681 - y21:issue12677, r=Jarcho
Let `qualify_min_const_fn` deal with drop terminators

Fixes #12677

The `method_accepts_droppable` check that was there seemed overly conservative.
> Returns true if any of the method parameters is a type that implements `Drop`.
> The method can't be made const then, because `drop` can't be const-evaluated.

Accepting parameters that implement `Drop` should still be fine as long as the parameter isn't actually dropped, as is the case in the linked issue where the droppable is moved into the return place. This more accurate analysis ("is there a `drop` terminator") is already done by `qualify_min_const_fn` [here](f5e250180c/clippy_utils/src/qualify_min_const_fn.rs (L298)), so I don't think this additional check is really necessary?

Fixing the other, second case in the linked issue was only slightly more involved, since `Vec::new()` is a function call that has the ability to panic, so there must be a `drop()` terminator for cleanup, however we should be able to freely ignore that. [Const checking ignores cleanup blocks](https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/transform/check_consts/check.rs#L382-L388), so we should, too?

r? `@Jarcho`

----

changelog: [`missing_const_for_fn`]: continue linting on fns with parameters implementing `Drop` if they're not actually dropped
2024-06-11 22:38:52 +00:00
AurelienFT
c86b19f1ef Add lint to check manual pattern char comparison and merge its code with single_char_pattern lint 2024-06-11 21:56:14 +02:00
bors
9ddea51a73 Auto merge of #12912 - lochetti:fix_12824, r=dswij
Don't lint indexing_slicing lints on proc macros

This pr fixes https://github.com/rust-lang/rust-clippy/issues/12824

Even though the issue mentions the indexing case only, it was easy to apply the fix to the slicing case as well.

changelog: [`out_of_bounds_indexing`, `indexing_slicing`]: Don't lint on procedural macros.
2024-06-11 15:27:36 +00:00
bors
87c895ad83 Auto merge of #12915 - belyakov-am:lint/single_char_add_str, r=xFrednet
Handle single chars with `to_string()` for `single_char_add_str`

Add support for single chars / literals with `to_string()` call for `push_str()` and `insert_str()`.

changelog: [`single_char_add_str`]: handle single chars with `to_string()` call

Closes #12775
2024-06-11 11:08:45 +00:00
Renato Lochetti
f7515ae905
Don't lint indexing_slicing lints on proc macros 2024-06-10 09:08:56 +01:00
Artem Belyakov
55344c84a5 Handle single chars with to_string() for single_char_add_str 2024-06-09 21:01:00 +03:00
clubby789
5acc25e700 Update icu4x dependencies 2024-06-09 07:47:42 +01:00
Renato Lochetti
70ca9a1e7e
Lint manual_unwrap_or for it let cases 2024-06-08 14:39:03 +01:00
Lzu Tao
2855a876a7 fix typos of author lint 2024-06-08 12:31:49 +00:00
Lzu Tao
a0234b4e8b Ignore non ExprKind::{Path,Lit) inside const context
- remove now dead code in ASSERTIONS_ON_CONSTANTS
  cc #11966
- Partially revert "ignore `assertions-on-constants` in const contexts"
  This reverts commit c7074de420a2192fb40d3f2194a20dd0d1b65cc6.
2024-06-08 18:44:40 +07:00
Lzu Tao
ac600282a0 ignore assertions-on-constants in const contexts 2024-06-08 16:50:25 +07:00
Lzu Tao
e18b27aa2a add uitest for issue 12816 2024-06-08 16:50:25 +07:00
Lzu Tao
2c61b45576 do not lint on indexing inside const contexts 2024-06-08 16:50:25 +07:00
Lzu Tao
aff0e6d6d3 add uitest for indexing in unnecessary const items 2024-06-08 16:50:25 +07:00