Commit Graph

17281 Commits

Author SHA1 Message Date
Centri3 8cb6c86996 change category and refactor
Update raw_strings.rs

Revert "new lints for visibility"

This reverts commit 0e5a537d209727169769dc19cf86aef27122c092.

new lints for visibility
2023-06-27 05:16:40 -05:00
Centri3 cb52d19ce1 don't lint `needless_raw_string_hashes` when it's unnecessary 2023-06-27 05:12:00 -05:00
Catherine ec765d9516 Update raw_strings.rs 2023-06-27 05:12:00 -05:00
Centri3 bc744eb82b new lint `needless_raw_string` + refactor a bit
Thanks, #112373, for the snippet at line 75!
2023-06-27 05:12:00 -05:00
Centri3 1bf74fc303 add `needless_raw_string_hashes` lint
add semicolon in doctest
2023-06-27 05:12:00 -05:00
bors ecdea8cdd3 Auto merge of #11009 - Centri3:unneeded_field_pat, r=dswij
Don't lint code from external macros for 8 lints

Fixes #11008

changelog: [`unneeded_field_pattern`], [`redundant_pattern`], [`uneeded_wildcard_pattern`], [`double_neg`], [`separated_literal_suffix`], [`unseparated_literal_suffix`], [`mixed_case_hex_literals`], [`zero_prefixed_literal`]: Don't lint code from external macros

(wow, that's one hell of a changelog for such a small change...)
2023-06-27 09:30:55 +00:00
Catherine d29506794e Don't lint code from external macros 2023-06-26 15:10:06 -05:00
bors 15ed281699 Auto merge of #10426 - oli-obk:ui_test, r=Manishearth
Port clippy away from compiletest to ui_test

Reasons to do this:

* runs completely on stable Rust
* is easier to extend with new features
* has its own dogfood test suite, so changes can be tested in [the `ui_test` repo](https://github.com/oli-obk/ui_test)
* supports dependencies from crates.io without having to manually fiddle with command line flags
* supports `ui-cargo`, `ui`, `ui-toml` out of the box, no need to find and run the tests ourselves

One thing that is a big difference to `compiletest` is that if a test emits *any* error, you need to mark all of them with `//~ ERROR:` annotations. Since many clippy tests did not have annotations, I changed many lints to be `warn` in their test so that only the `stderr` output is tested.

TODO:

* [ ] check that this still works as a subtree in the rustc repo

changelog: none
<!-- changelog_checked -->

Note: at present the latest changes needed for clippy are only available as a git dependency, but I expect to publish a new crates.io version soon
2023-06-26 17:32:51 +00:00
Oli Scherer 0a87ce8662 Find the right `cargo-clippy` binary in CI 2023-06-26 14:30:19 +00:00
Oli Scherer 5bd97ac17a Update tests 2023-06-26 14:13:07 +00:00
Oli Scherer 514b6d04bb Port clippy away from compiletest to ui_test 2023-06-26 14:13:07 +00:00
bors 2a9cc31ac7 Auto merge of #11027 - blyxyas:dates_changelog, r=Manishearth
Update changelog's data ranges

Related to #10847
Instead of the non-descriptive commit ranges, now the changelog uses dates (much more illustrative, and cooler 😎 )
changelog:none
2023-06-26 11:49:53 +00:00
blyxyas aea731ebdb
update changelog's data ranges 2023-06-26 13:48:49 +02:00
bors 407bfd483a Auto merge of #11005 - Centri3:never_loop, r=giraffate
Check if `if` conditions always evaluate to true in `never_loop`

This fixes the example provided in #11004, but it shouldn't be closed as this is still an issue on like
```rust
let x = true;
if x { /* etc */ }`
```
This also makes `clippy_utils::consts::constant` handle `ConstBlock` and `DropTemps`.

changelog: [`never_loop`]: Check if `if` conditions always evaluate to true
2023-06-26 00:42:38 +00:00
bors 78e36d9f53 Auto merge of #10996 - Centri3:mem_forget, r=xFrednet
Lint `mem_forget` if any fields are `Drop`

Closes #9298
I think this way of doing it (`needs_drop`) should be fine.

---

changelog: Enhancement: [`mem_forget`]: Now lints on types with fields that implement `Drop`
[#10996](https://github.com/rust-lang/rust-clippy/pull/10996)
2023-06-25 09:40:13 +00:00
Catherine a5ae9044fb make note less verbose 2023-06-25 04:28:40 -05:00
bors a30ca62bdd Auto merge of #11022 - lochetti:fix_11014, r=dswij
Avoid linting `extra_unused_type_parameters` on procedural macros

Don't lint `extra_unused_type_parameters` if code was generated by procedural macro.

This PR fixes https://github.com/rust-lang/rust-clippy/issues/11014

changelog: [`extra_unused_type_parameters`] avoid linting macro-generated code
2023-06-25 07:09:38 +00:00
Renato Lochetti f0eb40c981
Avoid linting on procedural macros 2023-06-24 19:45:16 -03:00
bors 1b4c423f30 Auto merge of #11021 - y21:issue9493, r=llogiq
[`format_push_string`]: look through `match` and `if` expressions

Closes #9493.

changelog: [`format_push_string`]: look through `match` and `if` expressions
2023-06-24 18:59:58 +00:00
y21 fe856d383f [`format_push_string`]: look through match, if, if-let 2023-06-24 19:54:12 +02:00
bors 3cee98d1a3 Auto merge of #11019 - Centri3:ptr_arg, r=llogiq
[`ptr_arg`]: Don't lint when return type uses `Cow`'s lifetime

Closes #9218

changelog: [`ptr_arg`]: Don't lint when return type uses `Cow`'s lifetime
2023-06-24 10:36:22 +00:00
Catherine db4efe3f6d Don't lint `ptr_arg` when return type uses Cow's lifetime 2023-06-24 03:26:40 -05:00
bors ce0a48a9b6 Auto merge of #10994 - y21:issue8772, r=giraffate
[`type_repetition_in_bounds`]: respect MSRV for combining bounds

Fixes #8772.

changelog: [`type_repetition_in_bounds`]: respect msrv for combining `?Sized` bound
2023-06-23 00:31:04 +00:00
y21 75f9fbc93d update lint configuration 2023-06-23 02:07:05 +02:00
y21 33b6d0d206 rename MSRV alias, add MSRV to lint doc 2023-06-22 17:19:43 +02:00
Catherine 6a1084c26f Check if `if` conditions always evaluate to true in `never_loop` 2023-06-22 04:31:05 -05:00
bors 6ec23880f2 Auto merge of #10979 - y21:issue9909, r=giraffate
[`get_unwrap`]: include a borrow in the suggestion if argument is not an integer literal

Fixes #9909

I have to say, I don't really understand what the previous logic was trying to do, but this fixes the linked bug.
It was checking if the argument passed to `.get()` can be parsed as a usize (i.e. if it's an integer literal, probably?), and if not, it wouldn't include a borrow? I don't know how we came to that conclusion, but that logic doesn't work:
```rs
let slice = &[1, 2];
let _r: &i32 = slice.get({ 1 }).unwrap();
// previous suggestion: slice[{ 1 }]
// the suggestion should be: &slice[{ 1 }]
```
Here the argument passed to it isn't an integer literal, but it should still include a borrow, because it would otherwise change the type from `&i32` to `i32`.

The exception is that if the parent of the `get().unwrap()` expr is a dereference or a method call or the like, we don't need an explicit borrow because it's automatically inserted by the compiler

changelog: [`get_unwrap`]: include a borrow in the suggestion if argument is not an integer literal
2023-06-21 23:57:02 +00:00
bors 9fa4089410 Auto merge of #10993 - Centri3:iter_nth_zero, r=Manishearth
Don't lint [`iter_nth_zero`] in `next`

Closes #9820
This also *slightlyy* modifies the output of `iter_nth`, as I noticed the types' names weren't in backticks

changelog: [`iter_nth_zero`]: No longer lints in implementations of `Iterator::next`
2023-06-21 22:06:12 +00:00
Centri3 242807a9c1 Don't lint `iter_nth_zero` in `next` 2023-06-21 15:58:52 -05:00
Catherine b6f194b48c move to `drop_forget_ref` 2023-06-21 15:56:24 -05:00
bors b3fd7b8120 Auto merge of #10948 - Centri3:borrow_as_ptr, r=dswij
[`borrow_as_ptr`]: Ignore temporaries

Fixes #9884

changelog: [`borrow_as_ptr`]: Ignore temporaries
2023-06-21 17:07:52 +00:00
y21 bdb2a17107 declare needs_ref later 2023-06-21 09:16:25 +02:00
y21 3122e3d78f use let chains, move assignments out of block, add tests 2023-06-21 09:04:40 +02:00
bors b3ae038a80 Auto merge of #11000 - Centri3:doc_markdown, r=giraffate
add WebAssembly to test

r? `@giraffate`
changelog: none
2023-06-21 02:42:49 +00:00
Catherine 3b89984b56 add WebAssembly to test 2023-06-20 21:19:58 -05:00
bors 73e31d12b4 Auto merge of #10999 - Centri3:doc_markdown, r=Alexendoo
Add WebAssembly to allowed idents

Closes #10998
changelog: [`doc_markdown`]: No longer lints WebAssembly
2023-06-21 00:47:29 +00:00
Catherine e3b601a1aa Add WebAssembly to allowed idents 2023-06-20 18:12:20 -05:00
Catherine d8d59965f1 Lint `mem_forget` if fields are `Drop` 2023-06-20 13:37:03 -05:00
y21 765a6e4a90 put issue link between <> 2023-06-20 17:36:38 +02:00
y21 87c28b9463 [`type_repetition_in_bounds`]: respect msrv for combining maybe bounds 2023-06-20 17:24:46 +02:00
bors 62972ae2dd Auto merge of #10952 - Centri3:excessive_precision, r=dswij
Don't lint `excessive_precision` on inf

Fixes #9910

changelog: [`excessive_precision`]: No longer lints overflowing literals
2023-06-20 14:56:21 +00:00
bors 5da6174318 Auto merge of #10990 - y21:issue8634-partial, r=blyxyas,xFrednet
[`single_match`]: don't lint if block contains comments

Fixes #8634

It now ignores matches with a comment in the "else" arm

changelog: [`single_match`]: don't lint if block contains comments
2023-06-20 13:57:19 +00:00
bors 8fd021f504 Auto merge of #10986 - Centri3:undocumented_unsafe_blocks, r=Manishearth
Allow safety comment above attributes

Closes #8679

changelog: Enhancement: [`undocumented_safety_block`]: Added `accept-comment-above-attributes` configuration.
2023-06-20 05:04:46 +00:00
Centri3 cc2e49f695 allow safety comment above attributes 2023-06-19 23:46:57 -05:00
bors 1919dff4ee Auto merge of #10989 - ericmarkmartin:use-placeref-abstraction, r=Manishearth
Use placeref abstraction

rust-lang/rust#80647 suggests refactoring certain patterns with MIR places to use higher-level abstractions provided by the [`Place`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_middle/mir/struct.Place.html)/[`PlaceRef`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_middle/mir/struct.PlaceRef.html). While working on that issue, I found a couple candidates for such refactoring in clippy.

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none
2023-06-20 04:43:38 +00:00
bors 89294e1756 Auto merge of #10992 - blyxyas:fix-test_case_lib, r=Manishearth
`items_after_test_module`: Ignore in-proc-macros items

The library `test-case` is having some problems with this lint, ignoring proc macros should fix it.
Related to #10713 and frondeus/test-case#122

(Couldn't add test cases for this exact situation without importing the library, but I think the fix is simple enough that we can be pretty sure there won't be any problems :) )

changelog:[`items_after_test_module`]: Ignore items in procedural macros
2023-06-20 04:14:20 +00:00
bors 5b60388e5a Auto merge of #10930 - y21:issue9956, r=blyxyas,xFrednet
[`redundant_closure_call`]: handle nested closures

Fixes #9956.

This ended up being a much larger change than I'd thought, and I ended up having to pretty much rewrite it as a late lint pass, because it needs access to certain things that I don't think are available in early lint passes (e.g. getting the parent expr). I think this'll be required to fi-x #10922 anyway, so this is probably fine.
(edit: had to write "fi-x" because "fix" makes github think that this PR fixes it, which it doesn't 😅 )

Previously, it would suggest changing `(|| || 42)()()` to `|| 42()`, which is a type error (it needs parens: `(|| 42)()`). In my opinion, though, the suggested fix should have really been `42`, so that's what this PR changes.

changelog: [`redundant_closure_call`]: handle nested closures and rewrite as a late lint pass
2023-06-19 20:30:35 +00:00
bors f396004b25 Auto merge of #10975 - hehaoqian:fix_self_named_module_files, r=Centri3,xFrednet
Fix false positive of [self_named_module_files] and [mod_module_files]

changelog: [self_named_module_files] [mod_module_files]: No longer lints dependencies located in subdirectory of workspace

fixes #8887

---

First time contributor here, just read contribution guide today.

I have several questions:

1. ~Is it the correct way to use environment variable `CARGO_HOME` to get the location of cargo home directory?~
(Edit: Code no longer uses CARGO_HOME)
2. How to setup test for this PR? This involves multiple files and `CARGO_HOME` setup. ~Not sure how to do this.~
~Edit: Working on tests right now~ A workspace_test has been added
2023-06-19 20:14:21 +00:00
bors c8c03ea606 Auto merge of #10793 - c410-f3r:bbbbbbbbbbb, r=xFrednet
[`arithmetic_side_effects`] Fix #10792

Fix #10792

```
changelog: [`arithmetic_side_effects`]: Retrieve field values of structures that are in constant environments
```
2023-06-19 19:51:49 +00:00
blyxyas 62c9e0b87d
Ignore in-proc-macros items 2023-06-19 20:50:24 +02:00