Commit Graph

7528 Commits

Author SHA1 Message Date
Samuel Moelius f583fd18e4 Fix `unwrap_or_else_default` false positive 2023-07-19 06:45:33 -04:00
Centri3 dcfc6a20db check for fully qualified paths in `unnecessary_cast` 2023-07-19 05:24:17 -05:00
Catherine 4c79d8ace5 new lint `iter_skip_zero` 2023-07-19 03:26:15 -05:00
Catherine 19b0e84187 Remove the configuration option
Also no longer lints non-exported types now
2023-07-19 02:08:33 -05:00
Catherine 9d08502496 New lint [`string_lit_chars_any`] 2023-07-19 00:38:22 -05:00
bors d4a6634d37 Auto merge of #11175 - y21:issue11174, r=Manishearth
[`redundant_pattern_matching`]: include guard in suggestion

Fixes #11174

changelog: [`redundant_pattern_matching`]: include guard in suggestion
2023-07-18 20:37:30 +00:00
Guillaume Gomez 5e9e46278e Update `needless_pass_by_ref_mut` ui test 2023-07-18 22:21:02 +02:00
Alex Macleod f539e1a1db Remove unused flags from ui-cargo tests 2023-07-18 18:46:09 +00:00
Catherine f4b3bb19c1 Add `allow_private_error` config option 2023-07-18 10:26:22 -05:00
Catherine 75e1329aac New lint [`error_impl_error`] 2023-07-18 10:26:12 -05:00
bors 9f0cbfd7df Auto merge of #11140 - Centri3:four_forward_slashes, r=blyxyas
New lint [`four_forward_slashes`]

Closes #9212

changelog: New lint [`four_forward_slashes`]
2023-07-18 12:56:18 +00:00
Catherine 0d59d1d617 Rename to `needless_return_with_question_mark` 2023-07-18 00:23:41 -05:00
bors 747df85f95 Auto merge of #11171 - Centri3:tuple_array_conversions, r=llogiq
Rewrite [`tuple_array_conversions`]

Fixes #11100
Fixes #11144
Fixes #11124

#11082 still needs discussion and #11085 likely can't be fixed.

changelog: [`tuple_array_conversions`]: Move to `pedantic`
changelog: [`tuple_array_conversions`]: Don't lint if mutability of references changes
changelog: [`tuple_array_conversions`]: Don't lint if bindings don't come from the exact same pattern
changelog: [`tuple_array_conversions`]: Don't lint if bindings are used for more than just the conversion
2023-07-18 05:15:50 +00:00
Catherine c13cb54e25 New lint `needless_return_with_try` 2023-07-18 00:09:22 -05:00
y21 e7fd44f213 add guard to suggestion instead of not linting 2023-07-17 21:18:11 +02:00
y21 c26801ee92 [`redundant_pattern_matching`]: don't lint if if guards are present 2023-07-17 19:25:28 +02:00
bors 3e0170bff4 Auto merge of #11173 - Alexendoo:needless-return-fn-macro, r=Manishearth
Don't lint `needless_return` in fns across a macro boundary

Fixes #11167

changelog: none
2023-07-17 15:53:21 +00:00
Alex Macleod d24f0d056f Don't lint `needless_return` in fns across a macro boundary 2023-07-17 14:03:00 +00:00
Catherine 74a77047da Rewrite [`tuple_array_conversions`] 2023-07-17 05:36:50 -05:00
y21 c83d58f507 document that `write!`ing into a string never fails 2023-07-17 12:23:18 +02:00
y21 c3881569af new lint: `format_collect` 2023-07-17 12:13:34 +02:00
Philipp Krones d6d530fd0b Merge commit 'd9c24d1b1ee61f276e550b967409c9f155eac4e3' into clippyup 2023-07-17 10:22:32 +02:00
bors 568ccf3fc8 Auto merge of #11083 - sylvestre:autofix, r=dswij
[`semicolon_if_nothing_returned`]: add an autofix

changelog: [`semicolon_if_nothing_returned`]: add an autofix
2023-07-17 08:05:11 +00:00
Sylvestre Ledru 8ebdd62620 [`semicolon_if_nothing_returned`]: Update the tests with the autofix 2023-07-16 22:19:25 +02:00
xFrednet f928d78211
clippy-driver: Update bug URL to use the ice template 2023-07-16 11:51:01 +02:00
Caio 1f82f6ddf3 [significant_drop_tightening] Fix #11160 2023-07-14 13:51:34 -03:00
Mahdi Dibaiee fdb2e363d3 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Philipp Krones 415fdb2d1a
Merge remote-tracking branch 'upstream/master' into rustup 2023-07-14 13:36:16 +02:00
bors bafde54367 Auto merge of #11152 - Alexendoo:unnecessary-cast-applicability, r=Manishearth
Set `unnecessary_cast` suggestion to `MaybeIncorrect` for pointer casts

Closes #11113

changelog: none
2023-07-14 07:39:49 +00:00
Urgau 50da77521e Rename cast_ref_to_mut to invalid_reference_casting (clippy side) 2023-07-13 23:01:24 +02:00
syvb 8d258c1508 Add handling for None.unwrap_or(_else) 2023-07-13 13:05:49 -04:00
syvb c2aaa622eb Fix ICE on None.unwrap_or_default() 2023-07-13 13:00:10 -04:00
Alex Macleod ea36a9df75 Set `unnecessary_cast` suggestion to `MaybeIncorrect` for pointer casts
Removing casts may cause type inference to stop working which requires
manual intervention
2023-07-13 13:29:41 +00:00
bors 7ccf5d404b Auto merge of #11095 - Alexendoo:rustfmt-imports, r=Manishearth
Add `imports_granularity = "Module"` to rustfmt.toml

This lets rustfmt split/merge imports, `Module` seems to be the most common style in clippy

https://rust-lang.github.io/rustfmt/?version=v1.6.0&search=#imports_granularity

changelog: none

Almost all the updates other than the config file change are from `cargo dev fmt` or blessed tests, the exceptions being

- `tests/ui/single_component_path_imports.rs`
- `tests/ui/single_component_path_imports_nested_first.rs`
- `tests/ui/single_component_path_imports_self_after.rs`
- `tests/ui/single_component_path_imports_self_before.rs`
- `tests/ui/unsafe_removed_from_name.rs` (added a test with merged imports as a drive by)
- `tests/ui/wildcard_imports.rs`
- `tests/ui/wildcard_imports_2021.rs`
2023-07-13 12:54:52 +00:00
Alex Macleod 2811effe34 Add `imports_granularity = "Module"` to rustfmt.toml 2023-07-13 12:44:57 +00:00
bors a0e825786b Auto merge of #11147 - y21:issue11145, r=Alexendoo
[`arithmetic_side_effect`]: allow different types on the right hand side for `Wrapping<T>`

Fixes #11145

This lint has a list of allowed types, one of which is `Wrapping<T>`, but it was only actually allowed if the type on the right hand side was also `Wrapping<T>`, which meant that, for example, `Wrapping<u32> += u32` would still lint. It now allows binary ops involving `Wrapping<T>` regardless of the type on the rhs.
These impls have only existed since Rust 1.60.0, so that is probably why the lint was previously not handling this correctly

changelog: [`arithmetic_side_effect`]: allow different types on the right hand side for `Wrapping<T>` (e.g. `Wrapping<T> += T`)
2023-07-13 12:28:52 +00:00
Catherine 2e43d0c917 Improve suggestion and add more tests 2023-07-12 19:54:55 -05:00
Catherine 885ce610fe New lint [`four_forward_slashes`]
Make it trim the contents
2023-07-12 19:39:24 -05:00
bors df92b5284e Auto merge of #11123 - panosfol:master, r=giraffate
[`panic_in_result_fn`] remove `todo!`, `unimplemented!`, `unreachable!`

This commit fixes #11025 by removing checks for `todo!`, `unimplemented!` and `unreachable!`.

changelog: [`panic_in_result_fn`] remove `todo!`, `unimplemented!`, `unreachable!`
2023-07-12 23:57:29 +00:00
y21 c5fc61ca94 [`arithmetic_side_effect`]: allow different rhs type 2023-07-13 00:24:10 +02:00
bors 3b43b1e39c Auto merge of #11098 - y21:issue11093, r=giraffate
[`unnecessary_literal_unwrap`]: also lint `unwrap_(err_)unchecked`

Closes #11093

changelog: [`unnecessary_literal_unwrap`]: also lint `unwrap_unchecked` and `unwrap_err_unchecked`
2023-07-12 22:18:54 +00:00
bors 53d2938d62 Auto merge of #11045 - Alexendoo:extern-flags, r=flip1995
Use depinfo to discover UI test dependencies

changelog: none

context: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Building.20test.20dependencies

This restores [the old `EXTERN_FLAGS` method](4cf5bdc60c/tests/compile-test.rs (L67-L75)) of passing `--extern` flags for building UI tests with minor changes

- Unused deps were removed
- It's now a `Vec` of args instead of a command string
- It uses a `BTreeMap` so the extern flags are in alphabetical order and deterministic

I don't know if the `HOST_LIBS` part is still required, but I figured it best to leave it in for now. If the change is accepted we can take a look if it's needed in `rust-lang/rust` after the next sync

This isn't as pleasant as having a `Cargo.toml`, though there is something satisfying about knowing the dependencies are already built and not needing to invoke `cargo`

r? `@flip1995`
2023-07-12 22:02:55 +00:00
Panagiotis Foliadis c49c177e06 [`panic_in_result_fn`] remove `todo!`, `unimplemented!`, `unreachable!`
This commit fixes #11025 by removing checks for `todo!`,
`unimplemented!` and `unreachable!`.

Signed-off-by: Panagiotis Foliadis <pfoliadis@hotmail.com>
2023-07-12 22:19:01 +03:00
Eric Huss 660ef4ffe8 Ignore flaky clippy tests. 2023-07-12 06:59:57 -07:00
bors a8939e5eae Auto merge of #111717 - Urgau:uplift_fn_null_check, r=oli-obk
Uplift `clippy::fn_null_check` lint

This PR aims at uplifting the `clippy::fn_null_check` lint into rustc.

## `incorrect_fn_null_checks`

(warn-by-default)

The `incorrect_fn_null_checks` lint checks for expression that checks if a function pointer is null.

### Example

```rust
let fn_ptr: fn() = /* somehow obtained nullable function pointer */

if (fn_ptr as *const ()).is_null() { /* ... */ }
```

### Explanation

Function pointers are assumed to be non-null, checking for their nullity is incorrect.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler
2023-07-11 09:34:48 +00:00
y21 0b5dac0975 [`unnecessary_literal_unwrap`]: also handle unwrap_err_unchecked 2023-07-11 08:41:36 +02:00
y21 cd1c8532e9 [`unnecessary_literal_unwrap`]: lint `unwrap_unchecked` 2023-07-11 08:38:15 +02:00
Urgau 103949b241 Drop uplifted `clippy::fn_null_check` 2023-07-10 18:12:41 +02:00
y21 23ac72316d adjust applicability and suggest making binding mutable 2023-07-10 11:24:16 +02:00
bors 9058b040c8 Auto merge of #11096 - y21:issue11091, r=giraffate
[`manual_range_patterns`]: lint negative values

Fixes #11091.

Now also lints negative values in patterns (`-1 | -2 | -3`)

changelog: [`manual_range_patterns`]: lint negative values
2023-07-10 00:04:08 +00:00
bors 507d1c282e Auto merge of #11110 - y21:unnecessary_literal_unwrap_ignore_expn, r=Jarcho
[`unnecessary_literal_unwrap`]: don't lint if binding initializer comes from expansion

Fixes https://github.com/rust-lang/rust-clippy/discussions/11109

changelog: [`unnecessary_literal_unwrap`]: don't lint if binding initializer comes from expansion
2023-07-09 20:09:22 +00:00
bors ebd8d31542 Auto merge of #11055 - smoelius:try-this, r=dswij
"try this" -> "try"

Current help messages contain a mix of "try", "try this", and one "try this instead". In the spirit of #10631, this PR adopts the first, as it is the most concise.

It also updates the `lint_message_conventions` test to catch cases of "try this".

(Aside: #10120 unfairly contained multiple changes in one PR. I am trying to break that PR up into smaller pieces.)

changelog: Make help messages more concise ("try this" -> "try").
2023-07-09 15:07:25 +00:00
bors b46033e9ce Auto merge of #10900 - GuillaumeGomez:needless-pass-by-ref, r=llogiq
Add `needless_pass_by_ref_mut` lint

changelog: [`needless_pass_by_ref_mut`]: This PR add a new lint `needless_pass_by_ref_mut` which emits a warning in case a `&mut` function argument isn't used mutably. It doesn't warn on trait and trait impls functions.

Fixes #8863.
2023-07-09 14:25:10 +00:00
Samuel Moelius b4738a6b57 Add test for #10535 2023-07-08 19:11:15 -04:00
bors 6ae065ffd6 Auto merge of #11129 - c410-f3r:lock-1, r=Manishearth
[significant_drop_tightening] Fix #11128

Fix #11128

```
changelog: [`significant_drop_tightening`]: Consider manual alias of the `drop` function.
```
2023-07-08 21:10:43 +00:00
Caio 2be695bf29 [significant_drop_tightening] Fix #11128 2023-07-08 17:43:34 -03:00
bors 8e261c09bb Auto merge of #11049 - Centri3:manual_is_infinite, r=blyxyas,xFrednet
New lints [`manual_is_infinite`] and [`manual_is_finite`]

Closes #9665

changelog: New lints [`manual_is_infinite`] and [`manual_is_finite`]
[#11049](https://github.com/rust-lang/rust-clippy/pull/11049)
2023-07-08 18:45:35 +00:00
Catherine 41438c2b90 Refactor, remove `Constant::to_bits` 2023-07-08 13:17:35 -05:00
Catherine a5dfb68491 refactor 2023-07-08 13:11:56 -05:00
Centri3 844afbfeba use `other` instead of `self` 2023-07-08 13:02:54 -05:00
Centri3 004e89d4cf rename to `manual_partial_ord_and_ord_impl`
cargo dev fmt

cargo test passes

cargo test passes

refactor a lil

Update bool_comparison.stderr

heavily refactor + bump `clippy::version`

refactor

refactor

check bounds to increase accuracy, and add todos
2023-07-08 13:02:54 -05:00
Centri3 2a1fd22f81 implement `manual_partial_ord_impl`
first try at this
2023-07-08 13:02:38 -05:00
Nilstrieb 31d50a6e21 Delete `to_string_in_format_args_incremental.rs`
It fails CI and passes locally. It passes random directores in
`-Cincremental` so maybe something's up. It shouldn't block us here.
2023-07-08 17:17:40 +02:00
Alex Macleod 87373d7f52 Fix failing clippy tests
Comments out the C string literals due to https://github.com/rust-lang/rust/pull/113334

Fixes https://github.com/rust-lang/rust-clippy/issues/11121
2023-07-07 18:19:08 +00:00
y21 5cc0c04826 [`manual_range_patterns`]: lint negative values 2023-07-07 17:25:28 +02:00
Alex Macleod 4939a716e8 arc_with_non_send_sync: reword and move to suspicious 2023-07-07 12:02:05 +00:00
Catherine 5949f762bf Make suggestion give multiple alternatives 2023-07-06 20:27:21 -05:00
Catherine f12edfdb53 `manual_float_methods` 2023-07-06 20:27:21 -05:00
y21 6868c0a74b [`unnecessary_literal_unwrap`]: don't lint if binding initializer is expn 2023-07-05 13:03:34 +02:00
bors 1e656d8d6d Auto merge of #10970 - y21:read_line_without_trim, r=giraffate
new lint: `read_line_without_trim`

This adds a new lint that checks for calls to `Stdin::read_line` with a reference to a string that is then attempted to parse into an integer type without first trimming it, which is always going to fail at runtime.
This is something that I've seen happen a lot to beginners, because it's easy to run into when following the example of chapter 2 in the book where it shows how to program a guessing game.
It would be nice if we could point beginners to clippy and tell them "let's see what clippy has to say" and have clippy explain to them why it fails 👀

I think this lint can later be "generalized" to work not just for `Stdin` but also any `BufRead` (which seems to be where the guarantee about the trailing newline comes from) and also, matching/comparing it to a string slice that doesn't end in a newline character (e.g. `input == "foo"` is always going to fail)

changelog: new lint: [`read_line_without_trim`]
2023-07-05 00:13:59 +00:00
Guillaume Gomez f048f73251 Add warning about semver compatibility if it's a public function 2023-07-04 20:35:23 +02:00
bors 3f4e5999b2 Auto merge of #11094 - y21:issue11084, r=Alexendoo
[`useless_vec`]: add more tests and don't lint inside of macros

Closes #11084.

I realized that the fix I added in #11081 itself also causes an error in a suggestion when inside of a macro. Example:
```rs
macro_rules! x {
  () => {
    for _ in vec![1, 2] {}
  }
}
x!();
```
Here it would suggest replacing `vec![1, 2]` with `[x!()]`, because that's what the source callsite is (reminder: it does this to get the correct span of `x!()` for code like `for _ in vec![x!()]`), but that's wrong when *inside* macros, so I decided to make it not lint if the whole loop construct is inside a macro to avoid this issue.

changelog: [`useless_vec`]: add more tests and don't lint inside of macros

r? `@Alexendoo` since these were your tests, I figured it makes most sense to assign you
2023-07-03 21:07:44 +00:00
y21 85f535b25f add test cases for u32, f32, bool, String 2023-07-03 22:57:33 +02:00
y21 8fad54e8f9 new lint: `read_line_without_trim` 2023-07-03 22:51:38 +02:00
Guillaume Gomez c62c7fadac Update UI tests with new `needless_pass_by_ref_mut` lint 2023-07-03 22:25:36 +02:00
Guillaume Gomez a43bea1016 Add UI test for `needless_pass_by_ref_mut` 2023-07-03 22:25:36 +02:00
y21 b4549c50b5 [`useless_vec`]: add more tests for macro combinations 2023-07-03 19:48:27 +02:00
bors ba3bd8f0f1 Auto merge of #11078 - Centri3:11068, r=llogiq
[`needless_raw_string_hashes`]: Only reset hashes needed if not following quote

Fixes #11068

changelog: none
2023-07-03 17:01:27 +00:00
bors 3f17c5c388 Auto merge of #10924 - est31:manual_let_else_question_mark, r=Centri3,flip1995,Manishearth
Don't lint manual_let_else in cases where ? would work

Don't lint `manual_let_else` where the question mark operator `?` would be sufficient, that is, mostly in cases like:

```Rust
let v = if let Some(v) = ex { v } else { return None };
```

Also, this PR emits the `question_mark` lint for `let...else` patterns that could be written with `?` (also, only `return None` like cases).

```
changelog: [`manual_let_else`]: don't lint in cases where question_mark already lints
changelog: [`question_mark`]: lint for `let Some(...) = ex else { return None };`
```

Fixes  #8755
2023-07-03 14:18:32 +00:00
bors a959061763 Auto merge of #11081 - y21:issue11075, r=Manishearth
[`useless_vec`]: use the source span for initializer

Fixes #11075.

changelog: [`useless_vec`]: use the source span for the initializer expression when inside of a macro
2023-07-03 12:08:36 +00:00
y21 1f77f8cc3c [`useless_vec`]: use the source span 2023-07-03 13:40:33 +02:00
Catherine 9a581077d4 Fix FP [`needless_raw_string_hashes`] 2023-07-03 06:35:04 -05:00
bors 2b03bb08b2 Auto merge of #11077 - y21:issue11076, r=Manishearth
[`arc_with_non_send_sync`]: don't lint if type has nested type parameters

Fixes #11076

changelog: [`arc_with_non_send_sync`]: don't lint if type has nested type parameters

r? `@Manishearth`
2023-07-03 09:48:05 +00:00
y21 75c339cd0a [`arc_with_non_send_sync`]: look for nested type parameters 2023-07-03 11:35:25 +02:00
est31 6990eaa972 Don't suppress manual_let_else if question_mark is allowed
If question_mark is allowed, there is no overlap any more,
so we can just not suppress it.
2023-07-03 09:42:54 +02:00
bors c46ddeb9e1 Auto merge of #10987 - y21:type_id_on_box, r=llogiq
new lint: `type_id_on_box`

Closes #7687.

A new lint that detects calling `.type_id()` on `Box<dyn Any>` (and not on the underlying `dyn Any`), which can make up for some pretty confusing bugs!

changelog: new lint: [`type_id_on_box`]
2023-07-03 06:16:14 +00:00
bors ea4ca225fb Auto merge of #10920 - blyxyas:speedtest, r=llogiq
Add `SPEEDTEST`

In the `master` branch, we currently don't have any way to test the performance of a single lint in changes.
This PR adds `SPEEDTEST`, the environment variable which lets you do a speed test on a lint / category of tests with various configuration options.

Maybe we should merge this with `lintcheck` 🤔
See the book page for more information.

changelog:none
2023-07-02 15:48:50 +00:00
bors 83d0682d5e Auto merge of #11061 - Alexendoo:let-and-return-closures, r=llogiq
`let_and_return`: lint 'static lifetimes, don't lint borrows in closures

Fixes #11056

Now also ignores functions returning `'static` lifetimes, since I noticed the `stdin.lock()` example was still being linted but doesn't need to be since https://github.com/rust-lang/rust/pull/93965

changelog: none
2023-07-02 15:14:46 +00:00
Alex Macleod e29a5acf6f let_and_return: lint 'static lifetimes, don't lint borrows in closures 2023-07-02 14:25:40 +00:00
Philipp Krones 4aa4fecf89 Fix compile-test tests to work with the new ui_test crate 2023-07-02 15:07:39 +02:00
Philipp Krones cb3ecf7b79 Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup 2023-07-02 14:59:02 +02:00
bors 1990b72e8a Auto merge of #11058 - Centri3:typos, r=xFrednet
Fix typos

Just a couple misc typos I found

changelog: none
2023-07-02 12:11:30 +00:00
Catherine 885a18207f Fix typos 2023-07-02 07:11:05 -05:00
Catherine cb5d7e344a address comments 2023-07-01 12:37:16 -05:00
Catherine fbb3f759e2 update docs 2023-07-01 12:36:02 -05:00
Catherine 04b0857691 Typo 2023-07-01 12:36:02 -05:00
Catherine 24039ca2c6 Add msrv tests 2023-07-01 12:36:02 -05:00
Catherine 354172a18e New lint `manual_try_fold` 2023-07-01 12:36:02 -05:00
bors c7bf05c1a4 Auto merge of #11020 - Centri3:tuple_array_conversion, r=llogiq
New lint [`tuple_array_conversions`]

Closes #10748

PS, the implementation is a bit ugly 😅 ~~I will likely refactor soon enough :)~~ Done :D

changelog: New lint [`tuple_array_conversions`]
2023-07-01 15:27:35 +00:00
Samuel Moelius 420f3d11e8 "try this" -> "try" 2023-07-01 07:08:01 -04:00
Catherine efac83813d Make `eq_op` suggest `.is_nan()` 2023-06-30 11:43:02 -05:00
est31 86391abc70 Don't lint manual_let_else in cases where the question mark operator would work
Also, lint question_mark for `let...else` clauses that can be simplified to use `?`.
This lint isn't perfect as it doesn't support the unstable try blocks.
2023-06-30 18:01:27 +02:00
bors 2c40b99d08 Auto merge of #11048 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-06-30 14:09:53 +00:00
Philipp Krones 8010c3462d
Merge remote-tracking branch 'upstream/master' into rustup 2023-06-30 16:09:06 +02:00
y21 648d1ae8e0 lint on matches and pattern matching 2023-06-30 14:54:49 +02:00
bors 73f14176e3 Auto merge of #10774 - c410-f3r:lock-1, r=Jarcho
[significant_drop_tightening] Fix #10413

Fix #10413

This is quite a rewrite that unfortunately took a  large amount of time. I tried my best to comment what is going on to easy review but feel free to ask any question.

The problem basically is that the current algorithm is only taking into consideration single blocks which means that things like the following don't work or show unpredictable results.

```rust
let mutex = Mutex::new(1);
{
  let lock = mutex.lock().unwrap();
  {
    let _ = *lock;
  }
}
```

The solve the issue, each path that refers a lock is now being tracked individually.

```
changelog: [`significant_drop_tightening`]: Lift the restriction of only considerate single blocks
```
2023-06-30 02:51:15 +00:00
bors 3d4c536e87 Auto merge of #11013 - Centri3:redundant_rest_pattern, r=giraffate
New lint [`redundant_at_rest_pattern`]

Closes #11011

It's always a great feeling when a new lint triggers on clippy itself 😄

changelog: New lint [`redundant_at_rest_pattern`]
2023-06-29 23:54:35 +00:00
Caio f0619024b8 Fix #10413 2023-06-29 09:27:49 -03:00
Catherine 826edd75ef heavily refactor 2023-06-29 06:46:28 -05:00
Catherine 95b24d44a6 Fix FP 2023-06-29 06:46:28 -05:00
Catherine b1acbde618 Add msrv check and make test pass 2023-06-29 06:46:28 -05:00
Catherine bfcc8ba444 New lint `tuple_array_conversions` 2023-06-29 06:46:00 -05:00
bors 9020937bbe Auto merge of #11030 - darklyspaced:master, r=Centri3,xFrednet
suggests `is_some_and` over `map().unwrap`

changelog: Enhancement: [`option_map_unwrap_or`] now considers the [`msrv`] config when creating the suggestion.

 * modified option_map_unwrap_or lint to recognise when an `Option<T>` is mapped to an `Option<bool>` with false being used when `None` is detected; suggests the use of `is_some_and` instead
 * msrv is set to 1.70.0 for this lint; when `is_some_and` was stabilised

fixes #9125
2023-06-29 09:54:51 +00:00
Alex Macleod 4340a8a0f2 Use depinfo to discover UI test dependencies 2023-06-28 23:01:24 +00:00
bors 10ce1a6d5e Auto merge of #11001 - y21:issue8628, r=Jarcho
[`question_mark`]: don't lint inside of `try` block

Fixes #8628.

Diff looks a bit noisy because I had to move the two functions into an impl, because they now need to access the structs `try_block_depth` field to see if they're inside a try block.

changelog: [`question_mark`]: don't lint inside of `try` block
2023-06-28 18:38:44 +00:00
bors ea4c5c5ca5 Auto merge of #11035 - y21:issue10729, r=Jarcho
[`option_if_let_else`]: suggest `.as_ref()` if scrutinee is of type `&Option<_>`

Fixes #10729

`Option::map_or` takes ownership, so if matching on an `&Option<_>`, we need to suggest `.as_ref()` before calling `map_or` to get the same effect and to not cause a borrowck error.

changelog: [`option_if_let_else`]: suggest `.as_ref()`/`.as_mut()` if scrutinee is of type `&Option<_>`/`&mut Option<_>`
2023-06-28 15:39:04 +00:00
y21 cee4c4169c allow dead code in the test 2023-06-28 17:00:54 +02:00
blyxyas 57923c3720
Finally fix dogfood 2023-06-28 16:03:59 +02:00
y21 70610c0018 lint in nested bodies if `try` is in outer body 2023-06-28 12:41:18 +02:00
bors 750c7a11da Auto merge of #11042 - y21:issue10459, r=Manishearth
[`unused_async`]: don't lint if function is part of a trait

Fixes #10459.

We shouldn't lint if the function is part of a trait, because the user won't be able to easily remove the `async`, as this will then not match with the function signature in the trait definition

changelog: [`unused_async`]: don't lint if function is part of a trait
2023-06-28 09:54:20 +00:00
Catherine 46aa8abf08 Change category and update to `ui_test` 2023-06-28 03:20:21 -05:00
Centri3 8296a338db new lints for visibility 2023-06-28 03:20:21 -05:00
bors 1df9110b85 Auto merge of #11043 - Alexendoo:testname, r=Jarcho
Use substring matching for TESTNAME

Restores the previous behaviour of matching using a substring match rather than needing a full match

changelog: none
2023-06-28 02:53:40 +00:00
bors 9e57657b79 Auto merge of #10968 - y21:manual_range_pat, r=Centri3
new lint: `manual_range_patterns`

Fixes #4931

changelog: new lint: [`manual_range_patterns`]
2023-06-27 21:07:13 +00:00
Alex Macleod 8647e29159 Use substring matching for TESTNAME 2023-06-27 20:36:05 +00:00
y21 b592d39968 manual_range_pattern -> manual_range_patterns 2023-06-27 22:35:54 +02:00
y21 1d4afc5d82 new lint: `manual_range_pattern` 2023-06-27 22:34:31 +02:00
y21 a43bfefd19 [`unused_async`]: don't lint on async trait impls 2023-06-27 22:30:38 +02:00
bors 6ce656f157 Auto merge of #11039 - Alexendoo:bless, r=llogiq
Add `BLESS` for compile-test and some cleanup

changelog: none

Allows passing the environment variable `BLESS` to bless tests, which is useful when you want to bless internal tests - `BLESS= cargo uitest -Finternal`

Also updates a place in the docs referring to `cargo dev bless` and removes some unused test deps
2023-06-27 20:25:06 +00:00
Alex Macleod 95ab05de25 Fix compile-test under cargo nextest 2023-06-27 18:25:35 +00:00
Alex Macleod 76de5560fa Add BLESS for compile-test and some cleanup 2023-06-27 16:39:13 +00:00
Catherine e9ced12512 Rename the lint 2023-06-27 06:31:04 -05:00
blyxyas 0cd8bbc867
Fix dogfood 2023-06-27 13:11:07 +02:00
Catherine 9a8347ded5 New lint [`redundant_rest_pattern`] 2023-06-27 06:06:56 -05:00
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
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
darklyspaced c60222dc12
changed the msrv to 1.70 to suggest `is_some_and`
if the msrv is not >= 1.70 then the `map_or` is suggested instead of `is_some_and` (even when `unwrap_or` returns false)
2023-06-27 11:29:02 +08:00
darklyspaced 9b7d8d1dc7
suggests `is_some_and` over `map().unwrap_or(false)` 2023-06-27 11:29:02 +08:00
Catherine d29506794e Don't lint code from external macros 2023-06-26 15:10:06 -05:00
blyxyas d69c4f553c
Add `SPEEDTEST` 2023-06-26 20:32:32 +02:00
y21 733a9ea6b9 [`option_if_let_else`]: suggest `.as_ref()` if `&Option<_>` 2023-06-26 20:13:06 +02: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
Oli Scherer 7bd8ab77e5 Make simd_shuffle_indices use valtrees 2023-06-26 09:34:52 +00: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