Commit Graph

20244 Commits

Author SHA1 Message Date
Jason Newcomb
95348adcb9 manual_float_methods:
* Check HIR tree first.
* Use `partition_in_place`.
2024-07-07 18:07:16 -04:00
Jason Newcomb
b9ba340db6 manual_bits: Delay msrv check 2024-07-07 18:06:36 -04:00
Jason Newcomb
c0fa6a92f0 literal_representation: Delay macro check. 2024-07-07 18:06:27 -04:00
Jason Newcomb
15f640a7cb let_with_type_underscore:
* Delay macro check.
* Use `is_from_proc_macro
2024-07-07 18:06:17 -04:00
Jason Newcomb
5332def0fd let_underscore: Delay macro check. 2024-07-07 18:06:00 -04:00
Jason Newcomb
fed75b3895 let_if_seq: use array_windows. 2024-07-07 18:05:51 -04:00
Jason Newcomb
ff4e62d3ec len_zero: Check HIR tree first 2024-07-07 18:05:41 -04:00
Alex Macleod
eac1aab1ff Reduce the size of lintcheck JSON output 2024-07-07 21:05:51 +00:00
Jason Newcomb
5ae33c7699 legacy_numeric_constants: Check HIR tree first. 2024-07-07 16:52:59 -04:00
Jason Newcomb
03036c11b3 large_include_file: Check HIR tree first. 2024-07-07 16:52:33 -04:00
Jason Newcomb
c3dd028d3e large_futures: Delay macro check 2024-07-07 16:52:13 -04:00
Jason Newcomb
430c02cbd0 large_enum_variant: Delay macro check 2024-07-07 16:51:58 -04:00
Jason Newcomb
3092c8a5fd large_const_arrays: Check HIR tree first. 2024-07-07 16:51:33 -04:00
Jason Newcomb
6b10b4360c iter_without_into_iter: Delay macro check 2024-07-07 16:51:20 -04:00
Jason Newcomb
fa1a690b23 iter_not_returning_iterator:
* Check HIR tree first.
* Check name by symbol.
2024-07-07 16:43:07 -04:00
Jason Newcomb
ca5c2813eb items_after_statements: Do less work in the default case. 2024-07-07 16:41:36 -04:00
Jason Newcomb
aef0710054 instant_subtraction: Reduce redundant work. 2024-07-07 16:37:51 -04:00
Jason Newcomb
dc8403f0f5 inline_fn_without_body: inline into a single function 2024-07-07 16:37:31 -04:00
Jason Newcomb
8e2ddc800b inherent_to_string: Check HIR tree before checking for macros. 2024-07-07 16:35:05 -04:00
bors
a4132817fb Auto merge of #13052 - xFrednet:00000-lintcheck-warn-all, r=Alexendoo
Lintcheck: Add `--warn-all` and make it the CI default

This PR adds a new `--warn-all` flag to lintcheck. This is intended for our CI, as it currently doesn't detect changes of `nursery` and `restriction` lints.

I only made it the default for the CI, as `restriction` lints tend to generate A LOT of lint triggers. Looking at you [`clippy::implicit_return`](https://rust-lang.github.io/rust-clippy/master/index.html#/clippy::implicit_return)

That's it. Should hopefully be easy to review.

Also, a bit thanks again to `@Alexendoo` for adding this to our CI ❤️

---

r? `@Alexendoo`

changelog: none
2024-07-07 18:30:39 +00:00
xFrednet
93e74a4187
Lintcheck: Update lintcheck documentation 2024-07-07 18:42:09 +02:00
Maybe Waffle
791ff40337 Add support for mir::TerminatorKind::TailCall in clippy 2024-07-07 17:11:05 +02:00
bors
09c07ed63f Auto merge of #13048 - Jarcho:disallowed_methods, r=blyxyas
Refactor `disallowed_methods` and narrow span

Using the span of the call site just produces noisy diagnostics for long calls. Especially multi-line calls.

changelog: none
2024-07-07 14:28:44 +00:00
Jason Newcomb
d2ff2b9850 Move panicking_overflow_checks into correctness and clean up docs. 2024-07-07 10:24:46 -04:00
Jason Newcomb
23d96f65e4 Rename overflow_check_conditional to panicking_overflow_checks. 2024-07-07 10:24:42 -04:00
Jason Newcomb
aa371c37c2 Rewrite overflow_check_conditional 2024-07-07 10:22:29 -04:00
bors
f2c74e220b Auto merge of #12966 - Rudxain:patch-1, r=dswij
Clarify that `modulo_one` only applies to ints

changelog: [`modulo_one`]: (docs) Clarify that it only applies to integers

This might be nitpicky, but it's more technically correct.

It also helps if a user skims through the docs, because they may believe it also applies to `{float}`s. This doc edit minimizes that possibility
2024-07-07 10:21:47 +00:00
John Arundel
5a9e5e4acf resolve code review comments 2024-07-07 10:49:26 +01:00
John Arundel
f7050b0c78 resolve code review comments 2024-07-07 10:44:27 +01:00
Michael Goulet
7ce4a49911 iter_identity is a better name 2024-07-07 00:12:35 -04:00
lukas
e0f32e09de Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
bors
0c9016aa1e Auto merge of #13055 - Jarcho:auto_derive, r=Alexendoo
Only check for `automatically_derived` on impl blocks

This brings us in line with how rustc checks for the attribute. Also note that `unused_attributes` will trigger if it's placed anywhere else.

See:
9a21ac8e7e/compiler/rustc_passes/src/dead.rs (L400-L403)
9a21ac8e7e/compiler/rustc_passes/src/liveness.rs (L143-L148)

changelog: none
2024-07-06 12:01:28 +00:00
Jason Newcomb
d8fb164a7c Rename any_parent_is_automatically_derived to in_automatically_derived. Only check for the attribute on an impl block. 2024-07-06 00:24:48 -04:00
y21
ecbb2d7ba9 remove internal compiler_lint_functions lint 2024-07-06 00:51:58 +02:00
bors
3ed690f07a Auto merge of #12974 - alex-semenyuk:rename_thread_local_initializer_can_be_made_const, r=Alexendoo
Rename thread_local_initializer_can_be_made_const to missing_const_for_thread_local

Close #12934
As discussed at #12934 name `thread_local_initializer_can_be_made_const` sounds against convention for other lints which describe the issue/wrong code but not suggestion and it is quite long. The new name take example from existing lint `missing_const_for_fn`

changelog: `thread_local_initializer_can_be_made_const` : Rename to [`missing_const_for_thread_local`]
2024-07-05 17:50:06 +00:00
xFrednet
25bb612538
Lintcheck: Add --warn-all and make it the CI default 2024-07-05 16:42:20 +02:00
Alexey Semenyuk
6621e6cbfa Rename thread_local_initializer_can_be_made_const to missing_const_for_thread_local 2024-07-05 19:40:37 +05:00
bors
94a000b613 Auto merge of #11293 - mrnossiom:11234, r=Jarcho
feat: add cfg_not_test lint

<!--
- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[ ] Added lint documentation
- \[x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
-->

Fixes #11234

changelog: new lint: [`cfg_not_test`]

I don't know whether to lint only the `attr` or also the item associated to it. I guess this would mean putting the check in another place than `check_attribute` but I can't find a way to get the associated item to the attribute.

Also, I'm not sure how to document this lint, I feel like my explications are bad.
2024-07-05 11:42:47 +00:00
bors
3ef366705b Auto merge of #13049 - Jarcho:is_in_test, r=Alexendoo
Remove `is_in_test_module_or_function`

Uses are replaced with `is_in_test` for consistency with other lints and to simplify the implementation of the lints. This means the module name is no longer checked, but that was a horrible hack from a time when late passes couldn't see `#[cfg(..)]` attributes.

changelog: none
2024-07-05 11:33:46 +00:00
Milo Moisson
dd37441a64
test: add cfg_not_test tests 2024-07-05 10:28:26 +02:00
Milo Moisson
2c09ac3d39
feat: add cfg_not_test lint 2024-07-05 10:28:26 +02:00
bors
e7f2952f7e Auto merge of #13047 - Jarcho:script, r=y21
Refactor `disallowed_script_idents`

Minor change to use `find_map` instead of a loop. Not important, but it's easier to read.

changelog: none
2024-07-05 06:47:49 +00:00
Jason Newcomb
6d61bdabea Use is_in_test in more places. 2024-07-05 02:42:58 -04: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
Jason Newcomb
4c44b4e3c8 Remove is_test_module_or_function and use is_in_test instead. 2024-07-05 02:17:24 -04:00
Jason Newcomb
ac939ad3a1 Refactor disallowed_script_idents: Simplify script checking loop. 2024-07-05 02:04:43 -04:00
bors
885f97e2ce Auto merge of #11656 - y21:unnecessary_string_from_utf8, r=Jarcho
[`unnecessary_to_owned`]: catch `to_owned` on byte slice to create temporary `&str`

Closes #11648

Detects the pattern `&String::from_utf8(bytes.to_vec()).unwrap()` and suggests `core::str::from_utf8(bytes).unwrap()`, which avoids the unnecessary intermediate allocation.

I decided to put this in the existing `unnecessary_to_owned` lint (rather than creating a new lint) for a few reasons:
- we get to use some of its logic (for example, recognizing any of the functions in the `to_owned` family, e.g. `to_vec`)
- the actual inefficient operation that can be avoided here is the call to `.to_vec()`, so this is in a way similar to the other cases caught by `unnecessary_to_owned`, just through a bunch of type conversions
- we can make this more "generic" later and catch other cases, so imo it's best not to tie this lint specifically to the `String` type

changelog: [`unnecessary_to_owned`]: catch `&String::from_utf8(bytes.to_vec()).unwrap()` and suggest `core::str::from_utf8(bytes).unwrap()`
2024-07-05 02:04:06 +00:00
Jason Newcomb
9d8a17794f Refactor bool_to_int_with_if:
* Check hir structure before macro checks
* Simplify constant checking
2024-07-04 21:52:46 -04:00
Jason Newcomb
d9ab0a70f6 Refactor assigning_clones:
* Merge some code paths
* Use `find` instead of a loop
* Move macro check to after hir pattern matching
2024-07-04 21:51:27 -04:00
bors
0aac16e5b2 Auto merge of #13037 - J-ZhengLi:issue13008, r=llogiq
[`missing_const_for_fn`]: fix suggestions for fn with abi that requires `const_extern_fn` feature

closes: #13008

---

changelog: [`missing_const_for_fn`]: fix suggestions for fn with abi that requires `const_extern_fn` feature.
2024-07-05 00:20:56 +00:00