Commit Graph

17512 Commits

Author SHA1 Message Date
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
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
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
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
bors
410456da51 Auto merge of #11116 - y21:format_collect, r=Manishearth
new lint: `format_collect`

A perf lint that looks for `format!`ing inside of `map`, then collecting it into a `String`. Did a quick benchmark locally and it's a bit more than 2x faster with fold.
`write!` is still not optimal (presumably because the fmt stuff goes through dynamic dispatch), but it's still a lot better than creating a new string on every element.
I thought about making a machine applicable suggestion, but there's a lot of suggestions that need to be made here, so I decided to just add help messages.

changelog: new lint: `format_collect`
2023-07-17 15:38:33 +00:00
Alex Macleod
d24f0d056f Don't lint needless_return in fns across a macro boundary 2023-07-17 14:03:00 +00:00
bors
54fa92287b Auto merge of #11172 - Alexendoo:tuple-array-conversions-nursery, r=xFrednet
Move tuple_array_conversions to nursery

changelog: Move [`tuple_array_conversions`] to `nursery` (Now allow-by-default)
<!-- FIY: Ignore this change, if the commit gets backported and also https://github.com/rust-lang/rust-clippy/pull/11146 -->
[#11172](https://github.com/rust-lang/rust-clippy/pull/11172)

The nursery change got lost in #11146 and it ended up in pedantic, this puts it in nursery and gives something to backport

r? `@xFrednet`
2023-07-17 12:18:27 +00:00
Alex Macleod
36f84a6176 Move tuple_array_conversions to nursery 2023-07-17 12:09:20 +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
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
bors
91095334bf Auto merge of #11168 - xFrednet:00000-free-ice-cream, r=flip1995
Update bug URL to use the ice template

The previous URL linked to the blank new issue from without any template. This will now link to the ICE template :)

* Before: https://github.com/rust-lang/rust-clippy/issues/new
* After: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

That's it, nothing too interesting besides that. For everyone reading this: here, have some free cream 🍨 🍦 and have a beautiful day. 🙃

changelog: none
2023-07-17 07:47:23 +00:00
Sylvestre Ledru
8ebdd62620 [semicolon_if_nothing_returned]: Update the tests with the autofix 2023-07-16 22:19:25 +02:00
bors
d9c24d1b1e Auto merge of #11169 - y21:new_lint_unelide_lifetimes, r=xFrednet
don't hide lifetimes for `LateContext`

Running `cargo dev new_lint --type methods` creates the lint file with hidden lifetimes for the `LateContext` parameter (i.e. `&LateContext`, when it should be `&LateContext<'_>`). This is already warned on with `#![warn(rust_2018_idioms)]`, so clippy should not use hidden lifetimes

changelog: none
2023-07-16 19:56:51 +00:00
y21
498db80d5c don't hide lifetimes for LateContext 2023-07-16 21:37:53 +02:00
Sylvestre Ledru
eaccc6d38f [semicolon_if_nothing_returned]: enable the autofix 2023-07-16 19:37:42 +02:00
xFrednet
f928d78211
clippy-driver: Update bug URL to use the ice template 2023-07-16 11:51:01 +02:00
bors
1d33469658 Auto merge of #11157 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-07-14 11:37:23 +00:00
Philipp Krones
753c30f347
Bump nightly version -> 2023-07-14 2023-07-14 13:36:32 +02:00
Philipp Krones
faa07d334a
Bump Clippy version -> 0.1.73 2023-07-14 13:36:23 +02: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
bors
4b355d8f31 Auto merge of #11154 - Alexendoo:track-clippy-conf-dir, r=flip1995
Trigger a rebuild when `CLIPPY_CONF_DIR` changes

changelog: none

This is a fix for https://github.com/rust-lang/rust-clippy/issues/9928#issuecomment-1634698183, any time `CLIPPY_CONF_DIR` changes cargo will now rebuild the crate clippy is being run on, giving it a chance to lint with the (potentially) different config file

r? `@flip1995`
2023-07-13 21:31:11 +00:00
Alex Macleod
36279f1b63 Trigger a rebuild when CLIPPY_CONF_DIR changes 2023-07-13 20:06:12 +00: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
bors
631faa1bc7 Auto merge of #11146 - hydro-project:tuple-array-conversions, r=Centri3,xFrednet
[`tuple_array_conversions`]: move from `complexity` to `nursery`

The lint suggestion is arguably often less readable and more complex than the original code.

For example, which of the following is the most readable:
```rust
let _vertices = edges.flat_map(|(src, dst)| [src, dst]);
let _vertices = edges.flat_map(<_ as Into<[i32; 2]>>::into);
let _vertices = edges.flat_map(<[i32; 2]>::from);
```

The lint can be useful, but really only applies if the tuple is either long enough that naming the fields is silly (maybe at least 4 entries long), or if the author intends the fields to be homogenous, which is author intent and can't be determined by the lint. Therefore I think the lint should be marked as pedantic.

Currently, there are also a lot of false positives with the lint:
* https://github.com/rust-lang/rust-clippy/issues/11082
* https://github.com/rust-lang/rust-clippy/issues/11085
* https://github.com/rust-lang/rust-clippy/issues/11100 (https://github.com/rust-lang/rust-clippy/pull/11105)
* https://github.com/rust-lang/rust-clippy/issues/11124
* https://github.com/rust-lang/rust-clippy/issues/11144

Should fix those issues before enabling it for everyone.

---

changelog: Move [`tuple_array_conversions`] to `nursery` (Now allow-by-default)
<!-- FIY: Ignore this change, if the commit gets backported -->
[#11146](https://github.com/rust-lang/rust-clippy/pull/11146)
2023-07-13 08:39:33 +00:00
bors
b10a0aa057 Auto merge of #11148 - smoelius:nb-known-problems, r=Jarcho
Add "Known problems" section to `needless_borrow` documentation

While this PR doesn't fix the issue in #11142, it at least communicates that this is a known limitation.

r? `@Jarcho`

changelog: Add "Known problems" section to `needless_borrow` documentation
2023-07-13 01:22:10 +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
Samuel Moelius
050b714c9d Add "Known problems" section to needless_borrow documentation 2023-07-12 20:15:54 -04: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
bors
d398e59163 Auto merge of #11138 - xFrednet:changelog-1-71, r=flip1995
Changelog for Rust 1.71 👑

Roses are red,
violets are blue,
new format is tried,
it's way less of a fight

---

Hey `@rust-lang/clippy,` `@blyxyas,` and `@Centri3,` I've tried the "new"/minimal changelog format we discussed a few meetings ago. I like it, and the writing process was also way quicker.

[🖼️ Rendered 🖼️](https://github.com/xFrednet/rust-clippy/blob/changelog-1-71/CHANGELOG.md#rust-171)

Furthermore, a big thank you to `@blyxyas` and `@Alexendoo` for updating the script that fetches the PR commits and adding links to the config values to the changelog. ❤️

---

changelog: none
2023-07-12 22:35:22 +00:00
Mingwei Samuel
4102a309d7 [tuple_array_conversions]: move from complexity to nursery
Due to outstanding issues:
* https://github.com/rust-lang/rust-clippy/issues/11082
* https://github.com/rust-lang/rust-clippy/issues/11085
* https://github.com/rust-lang/rust-clippy/issues/11100 (https://github.com/rust-lang/rust-clippy/pull/11105)
* https://github.com/rust-lang/rust-clippy/issues/11124
* https://github.com/rust-lang/rust-clippy/issues/11144
2023-07-12 15:28:46 -07: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
xFrednet
7a3756add5
Changelog: Add disclaimer about the new format 2023-07-12 14:41:39 +02:00
xFrednet
5ea622c8b2
Changelog for Rust 1.71 👑 2023-07-11 19:41:58 +02:00
xFrednet
31397b489a
Update version attribute for 1.71 lints 2023-07-11 19:23:42 +02: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