Commit Graph

17659 Commits

Author SHA1 Message Date
Morten Lohne
b5ef66f442 Optimize by doing a cheap check for double binary expression first 2023-08-05 21:28:08 +02:00
Morten Lohne
8f40d09e0f Add tests for const comparisons that compare two different types 2023-08-05 21:28:08 +02:00
Morten Lohne
08e1333fa6 Add missing variable decl to doc comment 2023-08-05 21:28:08 +02:00
Morten Lohne
e16a2ac0c6 Add descriptions for 'impossible_double_const_comparisons' and 'ineffective_double_const_comparisons' 2023-08-05 21:28:08 +02:00
Morten Lohne
046d3df35e New lints: impossible_double_const_comparisons and ineffective_double_const_comparisons 2023-08-05 21:28:08 +02:00
Morten Lohne
ab1281f54a fix: Make ConstEvalLateContext::new() public, to match the 'constant_context()' function that it replaced 2023-08-05 21:28:08 +02:00
bors
5818225a89 Auto merge of #11255 - blyxyas:fix-perf-sus_xor_used_as_pow, r=xFrednet
Fix `suspicious_xor_used_as_pow.rs` performance

The original `suspicious_xor_used_as_pow` lint had poor performance, so I fixed that + a little refactor so that module is readable.

**107 millis. -> 106 millis.** Using `SPEEDTEST` on Rust's VMs

fix #11060
changelog: [`suspicious_xor_used_as_pow`]: Improve performance by 0.934%
2023-08-03 20:07:54 +00:00
blyxyas
3fb84415cd
Fix suspicious_xor_used_as_pow.rs performance 2023-08-03 21:58:59 +02:00
bors
1eb254ef83 Auto merge of #11242 - samueltardieu:issue-11238, r=Centri3,giraffate
New lint `ignored_unit_patterns`

This idea comes from #11238. I've put the lint in `pedantic` as it might trigger numerous positives (three in Clippy itself).

changelog: [`ignored_unit_patterns`]: new lint
2023-08-03 01:04:39 +00:00
bors
237dd599db Auto merge of #11288 - Centri3:#11278, r=Alexendoo
[`ptr_as_ptr`]: Take snippet instead of pretty printing type

Fixes #11278

changelog: [`ptr_as_ptr`]: Include leading `super`s in suggestion
2023-08-02 22:32:35 +00:00
Catherine Flores
fef85c9083 Take snippet instead of pretty printing type 2023-08-02 17:26:25 -05:00
bors
97d1cfa2b4 Auto merge of #11286 - Centri3:#11283, r=Alexendoo
Suppress `question_mark` warning if `question_mark_used` is not allowed

Closes #11283

changelog: [`question_mark`]: Don't lint if `question_mark_used` is not allowed
2023-08-02 22:20:30 +00:00
Catherine Flores
4d49065a6c Suppress question_mark if question_mark_used is not allowed 2023-08-02 14:13:16 -05:00
bors
7af5ea14fc Auto merge of #11252 - Centri3:#11245, r=xFrednet
[`unwrap_used`]: Do not lint unwrapping on `!` or never-like enums

Fixes #11245

changelog: [`unwrap_used`]: Do not lint unwrapping on `!` or never-like enums
changelog: [`expect_used`]: Do not lint unwrapping on `!` or never-like enums
2023-08-02 19:02:47 +00:00
Catherine Flores
71c54137ea Extract never-like into clippy_utils 2023-08-02 14:00:26 -05:00
Catherine Flores
779e0f4021 Do not lint unwrapping on ! or never-like enums 2023-08-02 14:00:12 -05:00
bors
78f5e0d3ec Auto merge of #11284 - lengyijun:reorder, r=blyxyas
Alphabetically order arms in `methods/mod.rs` match

changelog: none

just order the arms in the match block
2023-08-02 11:45:32 +00:00
Your Name
72074a0f00 Alphabetically order arms in methods/mod.rs match 2023-08-02 16:44:26 +08:00
bors
588c1abb76 Auto merge of #11269 - y21:issue11268, r=Centri3
[`unnecessary_mut_passed`]: don't lint in macro expansions

Fixes #11268

changelog: [`unnecessary_mut_passed`]: don't lint in macro expansions
2023-08-01 05:15:09 +00:00
Samuel "Sam" Tardieu
f9a6dfa60d New lint ignored_unit_patterns 2023-07-31 22:00:53 +02:00
y21
dc1e8b0dd9 [unnecessary_mut_passed]: don't lint in macro expansions 2023-07-31 21:09:52 +02:00
bors
5436dba826 Auto merge of #11263 - c410-f3r:let-chain, r=Centri3
[`arithmetic_side_effects`] Fix #11262

Fix #11262

Rustc already handles paths that refer literals -> https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d795058a2e1634c867288c20ff9432c8

```
changelog: [`arithmetic_side_effects`]: Ignore paths that refer literals
```
2023-07-30 20:16:57 +00:00
bors
2ab124126d Auto merge of #11261 - y21:issue11260, r=blyxyas
[`unnecessary_find_map`]: look for then_some

Closes #11260

changelog: [`unnecessary_find_map`]: lint `.then_some()` in closure
2023-07-30 18:26:45 +00:00
Caio
35d434d08e [arithmetic_side_effects] Fix #11262 2023-07-30 14:33:38 -03:00
y21
be6a103c8c add more tests to unnecessary_find_map and unnecessary_filter_map 2023-07-30 16:52:53 +02:00
y21
008746cae4 [unnecessary_find_map]: look for then_some 2023-07-30 13:51:35 +02:00
bors
c0bdb3d337 Auto merge of #11258 - Jarcho:ice_11256, r=Centri3
Resolve type aliases in `type_certainty`

Fixes #11256

changelog: `unwrap_or_default`: Fix ICE when local types are declared using alias types
2023-07-30 07:57:47 +00:00
Jason Newcomb
caf601434b Resolve type aliases in type_certainty 2023-07-30 03:26:32 -04:00
bors
4c2f460dcc Auto merge of #8685 - Jarcho:redundant_closure_fixes, r=llogiq
`redundant_closure` fixes

fixes #8548

A good chunk of the code is fixing false negatives. The old code banned any non late-bound regions from appearing in the callee's signature. The new version checks when the late-bound region is actually required.

changelog: Better track when a early-bound region appears when a late-bound region is required in `redundant_closure`.
changelog: Don't lint `redundant_closure` when the closure gives explicit types.
2023-07-30 05:41:24 +00:00
Jason Newcomb
7423c2760b Don't lint redundant closure for any function call inserted by the compiler. 2023-07-30 01:19:36 -04:00
Jason Newcomb
4d80a2ed2e Rework redundant_closure
* Better track when a early-bound region appears when a late-bound region is required
* Don't lint when the closure gives explicit types.
2023-07-30 01:19:29 -04:00
Jason Newcomb
71cc39e1f2 Add debug assertions to implements_trait
Improve debug assertions for `make_projection`
2023-07-30 00:38:04 -04:00
bors
29730969b1 Auto merge of #11250 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-07-28 21:55:50 +00:00
Philipp Krones
65c5afd196
Bump nightly version -> 2023-07-28 2023-07-28 23:45:09 +02:00
Philipp Krones
3d60241841
Merge remote-tracking branch 'upstream/master' into rustup 2023-07-28 23:44:28 +02:00
bors
d3c5b488db Auto merge of #11210 - y21:readonly_write_lock, r=giraffate
new lint: [`readonly_write_lock`]

Closes #8555

A new lint that catches `RwLock::write` calls to acquire a write lock only to read from it and not actually do any writes (mutations).

changelog: new lint: [`readonly_write_lock`]
2023-07-28 13:08:02 +00:00
y21
5e88003dda pattern match on local usage slice to avoid ICE 2023-07-28 12:52:06 +02:00
bors
295bdc028f Auto merge of #10759 - blyxyas:unset_opt_env_unwrap, r=flip1995
Now `option_env_unwrap` warns even if a variable isn't set at compiletime

Fixes #10742
changelog: Fix false negative where `option_env_unwrap` wouldn't warn if the env variable isn't set at compile-time.
2023-07-27 19:52:46 +00:00
Timo
205a3741c1 make lint description more consistent (writer/reader -> write/read)
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2023-07-27 21:19:35 +02:00
y21
136339f2d3 new lint: [readonly_write_lock] 2023-07-27 21:19:35 +02:00
bors
42d3370d84 Auto merge of #113298 - tgross35:update-bless-envs, r=oli-obk
Unite bless environment variables under `RUST_BLESS`

Currently, Clippy and Miri both use an environment variable to indicate that output should be blessed, but they use different variable names. In order to improve consistency, this patch applies the following changes:

- Rename the variable `MIRI_BLESS` (as used in the Miri subtree) to `RUST_BLESS`
- Rename the variable `BLESS` (as used in the Clippy subtree) to `RUST_BLESS`
- Move emitting `RUST_BLESS` into `prepare_cargo_test` so it is always available (I need this for a WIP PR)

---

I prefer something like `RUST_BLESS` to `BLESS` just for a lower chance of conflict (not super common but other tools [do use `BLESS`](https://grep.app/search?q=%22BLESS%22&case=true&words=true&filter[lang][0]=Text&filter[lang][1]=Rust&filter[lang][2]=Python&filter[lang][3]=C%2B%2B&filter[lang][4]=Markdown&filter[lang][5]=C&filter[lang][6]=JSON)), but I can change it to whatever is preferred.

Original discussion: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/BLESS.20env.20var.3A.20rename.20to.20CLIPPY_BLESS

r? `@oli-obk`
cc `@flip1995`
2023-07-27 17:45:11 +00:00
blyxyas
3bfccacca9
Add comments + Very minor Refactor 2023-07-26 23:16:24 +02:00
Trevor Gross
6ca6be6f2b Unite bless environment variables under RUSTC_BLESS
Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to
indicate that output should be blessed, but they use different variable names.
In order to improve consistency, this patch applies the following changes:

- Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always
  available
- Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS`
- Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS`
- Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS`
- Adjust the blessable test in `rustc_errors` to use this same
  convention
- Update documentation where applicable

Any tools that uses `RUSTC_BLESS` should check that it is set to any value
other than `"0"`.
2023-07-26 16:54:02 -04:00
Matthias Krüger
8615595021 Rollup merge of #114070 - blyxyas:iter_mut_symbol, r=oli-obk
Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy

We currently have `sym::iter` and `sym::iter_repeat`, this PR adds `sym::iter_mut` as it's useful for https://github.com/rust-lang/rust-clippy/pull/11038 and another Clippy lint, it also adds `sym::as_mut_ptr` as it's useful for https://github.com/rust-lang/rust-clippy/pull/10962.
2023-07-26 20:49:13 +02:00
blyxyas
4e1db44404
Now option_env_unwrap warns even if a variable isn't set at compile time. 2023-07-26 18:57:57 +02:00
bors
d446378143 Auto merge of #11228 - matthiaskrgr:fix_integration_tests2__with_test, r=flip1995
test that we correctly detect panics in intergation tests

should be merged after https://github.com/rust-lang/rust-clippy/pull/11225

changelog: add test for integration tests
2023-07-26 15:21:41 +00:00
Matthias Krüger
01b9f9d9da ci: test that we fail CI if we don't find clippy panicking 2023-07-26 17:05:20 +02:00
bors
ed2ec819e9 Auto merge of #114054 - oli-obk:cleanups, r=estebank
Split some functions with many arguments into builder pattern functions

r? `@estebank`

This doesn't resolve all of the ones in rustc, mostly because I need to do other cleanups in order to be able to use some builder derives from crates.io

Works around https://github.com/rust-lang/rust/issues/90672 by making `x test rustfmt --bless` format itself instead of testing that it is formatted
2023-07-26 11:17:35 +00:00
bors
fc13bf8be2 Auto merge of #11225 - matthiaskrgr:fix_integration_tests2, r=flip1995
Fix integration tests #2

fix integration tests.

It turned out that the following tests fail to build at all:

chalk, combine, stdarch and hyper.

This is often a problem of passing `--all-targets --all-features`, in case of combine though, outdated deps were to blame.

I have opened tickets against combine and rustfmt
https://github.com/rust-lang/rustfmt/issues/5859
https://github.com/Marwes/combine/issues/357

should we just remove the other failing repos? :/

changelog: fix integration tests on ci
2023-07-26 08:55:48 +00:00
bors
80641c0ca2 Auto merge of #11231 - xFrednet:00000-merge-no-merge, r=flip1995
Add *no merge policy* note via rustbot

I just found out that ``@rustbot`` can automatically add a note about our *no-merge commits* policy, if it detects a merge commit: https://forge.rust-lang.org/triagebot/no-merge.html

Funnly enough, I found this while writing documentation for Marker. ``@rustbot`` is a cool tool 👍

---

r? `@flip1995` since you'll probably be the person that will see this message the most ^^

changelog: none
2023-07-26 08:33:18 +00:00