Commit graph

16281 commits

Author SHA1 Message Date
Samuel Tardieu
b6f0ebf71c help: refer to cargo check --help 2023-03-05 23:10:13 +01:00
bors
783bc621a1 Auto merge of #10438 - Jarcho:use_snip_ctxt, r=dswij
Use `snippet_with_context` more

No tests at the moment. Need to find a way to write macro tests without writing a pile of macros.

changelog: None
2023-03-05 15:24:36 +00:00
bors
70e85d146f Auto merge of #10403 - smoelius:fix-107877, r=Jarcho
Fix rust-lang/rust#107877, etc.

Fix #10009
Fix #10387
Fix https://github.com/rust-lang/rust/issues/107877

The fix is to verify that the associated item's trait is implemented before trying to project the item's type.

r? `@Jarcho`

---

changelog: ICE: [`needless_borrow`]: No longer panics on ambiguous projections
[#10403](https://github.com/rust-lang/rust-clippy/pull/10403)
<!-- changelog_checked -->
2023-03-05 01:15:46 +00:00
Samuel Moelius
f95d9deafd Handle ambiguous projections 2023-03-04 19:03:40 -05:00
bors
78f0f78826 Auto merge of #10445 - samueltardieu:lintcheck-maintenance, r=llogiq
Lintcheck maintenance

Make `cargo lintcheck -j 0` use all threads instead of panicking, and cleanup (and shorten) lintcheck's parsing code.

changelog: none
2023-03-04 23:37:00 +00:00
Samuel Tardieu
79829d8718 lintcheck: use clap's derive interface
This makes the code shorter and clearer.

The only incompatible change is that an explicit command-line argument
`--crates-toml=` will take precedence over the `LINTCHECK_TOML`
environment variable.
2023-03-04 23:17:27 +01:00
bors
2500f960fc Auto merge of #10439 - giraffate:fix_fp_for_let_unit_value, r=Jarcho
Fix FP for `let_unit_value` when `await` used

Fix https://github.com/rust-lang/rust-clippy/issues/10433

changelog: Fix FP for `let_unit_value` when `await` used
2023-03-04 19:42:26 +00:00
Samuel Tardieu
446ae429a6 lintcheck: fix parallel processing handling
Using `rayon::current_num_threads()` causes a bug:

```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
  ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }',
  src/main.rs:632:10
```

Moreover, using the number of threads and dividing it by 2 wouldn't
return the number of physical threads on modern processors which have
a varying number of threads per core.

It makes little sense to restrict ourselves to physical threads,
especially when, in modern architectures, cores with multiple threads
are often faster (performance) while cores with a unique threads are
often slower (efficient). The Rust runtime will make a better choice.
2023-03-04 17:29:58 +01:00
bors
308d680407 Auto merge of #10442 - dtolnay-contrib:letunderscore, r=llogiq
Downgrade let_underscore_untyped to restriction

From reading #6842 I am not convinced of the cost/benefit of this lint even as a pedantic lint.

It sounds like the primary motivation was to catch cases of `fn() -> Result` being changed to `async fn() -> Result`. If the original Result was ignored by a `let _`, then the compiler wouldn't guide you to add `.await`. **However, this situation is caught in a more specific way by [let_underscore_future](https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_future) which was introduced _after_ the original suggestion (#9760).**

In #10410 it was mentioned twice that a <kbd>restriction</kbd> lint might be more appropriate for let_underscore_untyped.

changelog: Moved [`let_underscore_untyped`] to restriction
2023-03-04 16:20:28 +00:00
bors
d423703aba Auto merge of #10443 - dtolnay-contrib:formerids, r=llogiq
Include former name of renamed lints in lints.json

I am interested in having a programmatic way to process [`RENAMED_LINTS`](113c704d22/clippy_lints/src/renamed_lints.rs (L4)) for https://github.com/dtolnay/noisy-clippy/issues/15.

<details>
<summary>lints.json diff</summary>

```diff
60c60,63
<     }
---
>     },
>     "former_ids": [
>       "almost_complete_letter_range"
>     ]
300c303,306
<     }
---
>     },
>     "former_ids": [
>       "option_and_then_some"
>     ]
330c336,340
<     }
---
>     },
>     "former_ids": [
>       "block_in_if_condition_expr",
>       "block_in_if_condition_stmt"
>     ]
450c460,463
<     }
---
>     },
>     "former_ids": [
>       "box_vec"
>     ]
945c958,961
<     }
---
>     },
>     "former_ids": [
>       "cyclomatic_complexity"
>     ]
1335c1351,1354
<     }
---
>     },
>     "former_ids": [
>       "derive_hash_xor_eq"
>     ]
1365c1384,1387
<     }
---
>     },
>     "former_ids": [
>       "disallowed_method"
>     ]
1380c1402,1405
<     }
---
>     },
>     "former_ids": [
>       "blacklisted_name"
>     ]
1410c1435,1438
<     }
---
>     },
>     "former_ids": [
>       "disallowed_type"
>     ]
1890c1918,1922
<     }
---
>     },
>     "former_ids": [
>       "option_expect_used",
>       "result_expect_used"
>     ]
3150c3182,3185
<     }
---
>     },
>     "former_ids": [
>       "zero_width_space"
>     ]
4185c4220,4225
<     }
---
>     },
>     "former_ids": [
>       "option_map_unwrap_or",
>       "option_map_unwrap_or_else",
>       "result_map_unwrap_or_else"
>     ]
4290c4330,4333
<     }
---
>     },
>     "former_ids": [
>       "if_let_some_result"
>     ]
4710c4753,4756
<     }
---
>     },
>     "former_ids": [
>       "eval_order_dependence"
>     ]
4755c4801,4804
<     }
---
>     },
>     "former_ids": [
>       "stutter"
>     ]
5055c5104,5107
<     }
---
>     },
>     "former_ids": [
>       "ref_in_deref"
>     ]
5400c5452,5455
<     }
---
>     },
>     "former_ids": [
>       "new_without_default_derive"
>     ]
5820c5875,5878
<     }
---
>     },
>     "former_ids": [
>       "logic_bug"
>     ]
6330c6388,6391
<     }
---
>     },
>     "former_ids": [
>       "to_string_in_display"
>     ]
6525c6586,6589
<     }
---
>     },
>     "former_ids": [
>       "const_static_lifetime"
>     ]
7065c7129,7132
<     }
---
>     },
>     "former_ids": [
>       "single_char_push_str"
>     ]
8820c8887,8891
<     }
---
>     },
>     "former_ids": [
>       "option_unwrap_used",
>       "result_unwrap_used"
>     ]
8925c8996,8999
<     }
---
>     },
>     "former_ids": [
>       "identity_conversion"
>     ]
```
</details>

changelog: Include `"former_ids": […]` for renamed lints in [lints.json](https://rust-lang.github.io/rust-clippy/master/lints.json)
2023-03-04 16:08:09 +00:00
David Tolnay
cc6180c2f4
Include former name of renamed lints in lints.json 2023-03-03 19:03:54 -08:00
David Tolnay
03b9940b29
Downgrade let_underscore_untyped to restriction 2023-03-03 13:40:07 -08:00
Takayuki Nakata
027f19c8b9 Fix FP for let_unit_value when await used 2023-03-03 22:41:39 +09:00
Jason Newcomb
efbcb99b73 Use snippet_with_context more 2023-03-03 00:55:53 -05:00
bors
113c704d22 Auto merge of #10427 - xFrednet:changelog-1-68, r=Manishearth
Update version attribute for 1.68 lints

Roses are red,
violets are blue,
I'm running out of rhymes,
changelogs are crimes????

---

changelog: none
<!-- changelog_checked -->
2023-02-28 21:24:26 +00:00
xFrednet
917ebc3af6
Changelog for Rust 1.68 🐶 2023-02-28 22:06:53 +01:00
xFrednet
7fb76a1ea7
Update version attribute for 1.68 lints 2023-02-28 21:56:03 +01:00
bors
2d9ca944fa Auto merge of #10425 - smoelius:docs, r=llogiq
Two small documentation improvements

The `wrong_self_convention` changes are for grammar and accuracy.

The `must_use_candidate` change is because that lint flags only exported functions: 8b65632b6e/clippy_lints/src/functions/must_use.rs (L27-L31)

changelog: `wrong_self_convention` and `must_use_candidate` documentation improvements
2023-02-28 18:16:15 +00:00
bors
ba86a99d24 Auto merge of #10324 - andrewbanchich:fix-missing-private-docs, r=dswij
Scope `missing_docs_in_private_items` to only private items

`missing_docs_in_private_items` currently detects missing docs for public items as well as private. Since `missing_docs`already covers public items, this PR updates `missing_docs_in_private_items` to only cover private items.

Fixes #1895

changelog: [`missing_docs_in_private_items`]: Apply lint only to private items (used to be public and private)
2023-02-28 16:30:49 +00:00
bors
d98873497b Auto merge of #10418 - Jarcho:finish_dogfood, r=flip1995
Run dogfood to completion

Run dogfood on all packages before failing the test. Failing early is painful on lints which trigger on multiple crates.

changelog: None
2023-02-28 15:21:32 +00:00
bors
1a11ad7390 Auto merge of #10405 - Jarcho:issue_10367, r=flip1995
Fix ICE in `multiple_unsafe_ops_per_block`

fixes #10367

changelog: [`multiple_unsafe_ops_per_block`]: Fix ICE when calling a function-like object in an unsafe block
2023-02-28 15:08:34 +00:00
bors
acf70eae4c Auto merge of #10423 - Alexendoo:array-size-threshold, r=flip1995
Fix array-size-threshold config deserialization error

changelog: Fix error when providing an `array-size-threshold` in `clippy.toml`

Not entirely sure why it doesn't want to deserialize a u128, but converting it after the fact is an easy enough fix

Fixes #10422
2023-02-28 14:57:33 +00:00
Samuel Moelius
90ba82bd39 Two small documentation improvements 2023-02-28 09:52:01 -05:00
Jason Newcomb
69a1100776 Run dogfood on all packages before failing 2023-02-28 09:49:54 -05:00
Alex Macleod
2cadea5dc5 Fix array-size-threshold config deserialization error 2023-02-28 14:37:41 +00:00
bors
8b65632b6e Auto merge of #10419 - deining:fix/typos, r=Jarcho
Fixing typos

changelog: none
2023-02-27 20:51:12 +00:00
Andreas Deininger
03a3f74365 Fixing typos 2023-02-27 21:45:26 +01:00
bors
2742ac0748 Auto merge of #10399 - samueltardieu:issue-10396, r=Manishearth
Do not suggest to derive `Default` on generics with implicit arguments

Fixes #10396

changelog: FP: [`derivable_impls`]: do not suggest to derive `Default` on generics with implicit arguments
2023-02-27 17:12:43 +00:00
bors
ba7fd68e87 Auto merge of #10408 - cdown:cdown/2023-02-26/exit_lint_sp, r=Alexendoo
exit lint: potentualy -> potentially

changelog: none
2023-02-26 20:51:54 +00:00
Chris Down
5f3df6cfce exit lint: potentualy -> potentially 2023-02-26 17:43:24 +00:00
Samuel Tardieu
c82ff00539 Do not suggest to derive Default on generics with implicit arguments 2023-02-26 15:44:04 +01:00
Jason Newcomb
002e934189 Don't assume paths work with fn_sig in multiple_unsafe_ops_pre_block. 2023-02-26 02:55:52 -05:00
bors
3d193fa17a Auto merge of #10400 - calebcartwright:rustfmt-cleanup, r=Jarcho
chore: remove unneeded rustfmt skip

---

The associated rustfmt bug that originally necessitated these skips was resolved a while back, so these are no longer necessary

changelog: none
2023-02-26 03:03:01 +00:00
bors
e1ac1332b6 Auto merge of #10375 - samueltardieu:issue-10371, r=Manishearth
Do not suggest using Self in const generic parameters

Fixes #10371

changelog: FP: [`use_self`]: do not suggest using `Self` in const generic parameters
2023-02-26 00:52:55 +00:00
Andrew Banchich
49a06ed66f Scope missing_docs_in_private_items to only private items 2023-02-25 19:16:53 -05:00
bors
149392b0ba Auto merge of #10402 - Jarcho:rustup, r=Jarcho
Rustup

Looks like `@flip1995`  is busy.

r? `@ghost`

changelog: None
2023-02-25 23:34:06 +00:00
Jason Newcomb
69c4ff6df8 Emit unnecessary_def_path in source order. 2023-02-25 18:09:24 -05:00
Jason Newcomb
e825adf637 Fix normalization of custom_ice_message test. 2023-02-25 18:08:51 -05:00
bors
51551193d8 Auto merge of #10401 - samueltardieu:issue-10148, r=Alexendoo
Do not panic when analyzing the malformed origin of a format string

Fixes #10148. This will trigger only when generating format strings while accepting weird things in a procedural macro and setting the span to something which is not a string.

changelog: none
2023-02-25 23:05:23 +00:00
Samuel Tardieu
64775f30c2 Do not panic when analyzing the malformed origin of a format string 2023-02-25 23:48:17 +01:00
Jason Newcomb
5552f4a6b5 Bump nightly version -> 2023-02-25 2023-02-25 17:44:05 -05:00
Jason Newcomb
bc184e9c7d Merge branch 'master' into rustup 2023-02-25 17:43:19 -05:00
Caleb Cartwright
730fa93634 chore: remove unneeded rustfmt skip 2023-02-25 12:34:05 -06:00
bors
b528cc90bc Auto merge of #10391 - ldm0:ldm0_fix_unwrap_in_tests, r=xFrednet
Fix test function checker in `unwrap_used`, `expect_used`

After #9686 , `unwrap` and `expect` in integration tests and raw test functions won't be allowed.

fixes #10011
fixes #10238
fixes #10264

---

changelog: Fix: [`expect_used`], [`unwrap_used`], [`dbg_macro`], [`print_stdout`], [`print_stderr`]: No longer lint in test functions, if the related configuration is set
[#10391](https://github.com/rust-lang/rust-clippy/pull/10391)
<!-- changelog_checked -->
2023-02-24 09:24:41 +00:00
Liu Dingming
84ceca852e run cargo collect-metadata 2023-02-24 05:53:58 +08:00
bors
659112ca95 Auto merge of #10369 - nindalf:no_mangle_lint, r=llogiq
Add new lint no_mangle_with_rust_abi

Fixes issue #10347

This PR adds a new lint `no_mangle_with_rust_abi` that suggests converting a function to the C ABI to if the function has the `#[no_mangle]` attribute and `Abi == Abi::Rust`. It will not run for any of the other variants defined in [rustc_target::spec::abi::Abi](https://doc.rust-lang.org/beta/nightly-rustc/rustc_target/spec/abi/enum.Abi.html), nor suggest any conversion other than conversion to the C ABI.

Functions that explicitly opt into the Rust ABI with `extern "Rust"` are ignored by this lint.

---

changelog: [`no_mangle_with_rust_abi`]: add lint that converts Rust ABI functions with the `#[no_mangle]` attribute to C ABI
2023-02-23 19:41:03 +00:00
Krishna Sundarram
00c294ad05 Add new lint no_mangle_with_rust_abi 2023-02-23 17:35:06 +00:00
bors
f9adb83e0a Auto merge of #10392 - mkrasnitski:false-positives, r=Jarcho
Fix more false positives for `extra_unused_type_parameters`

Builds on #10321. All empty functions are no longer linted, instead of just those that have trait bounds on them. Also, if a trait bound contains a non-public trait (un-exported, but still potentially reachable), then the corresponding type parameter isn't linted.

Finally, added support for the `avoid_breaking_exported_api` config option.

r? `@flip1995`
changelog: none
2023-02-23 15:53:39 +00:00
Michael Krasnitski
528bb639d4 Fix more false positives for extra_unused_type_parameters 2023-02-23 10:12:02 -05:00
bors
daa94d2583 Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compiler-errors,davidtwco,estebank,oli-obk
diagnostics: if AssocFn has self argument, describe as method

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links targeting methods.

For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods>

> Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation.

In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-23 00:19:12 +00:00