Commit Graph

15710 Commits

Author SHA1 Message Date
Philipp Krones
661f13ce3b
Bump nightly version -> 2022-11-21 2022-11-21 20:02:14 +01:00
Philipp Krones
25e98bf708
Bump Clippy version -> 0.1.67 2022-11-21 20:02:06 +01:00
Philipp Krones
fd5b85c957
Merge remote-tracking branch 'upstream/master' into rustup 2022-11-21 20:01:17 +01:00
Alex Macleod
637139d2ff Add clippy_utils::msrv::Msrv to keep track of the current MSRV 2022-11-21 18:16:40 +00:00
Oli Scherer
386d0a5c67 Add an always-ambiguous predicate to make sure that we don't accidentlally allow trait resolution to prove false things during coherence 2022-11-21 16:35:04 +00:00
Matthias Krüger
3597ed5a09 Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr
Add `PolyExistentialPredicate` type alias

Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.
2022-11-21 14:11:11 +01:00
kraktus
ed183ee9ac Fix [unnecessary_lazy_eval] when type has significant drop 2022-11-21 12:45:35 +01:00
bors
51ec465cc3 Auto merge of #9873 - smoelius:move-line-span, r=flip1995
Move `line_span` to source.rs

`line_span` is a non-public function used only in source.rs. It seems like it ought to go in source.rs.

changelog: none
2022-11-21 11:07:32 +00:00
bors
e0c1959616 Auto merge of #9592 - c410-f3r:arith, r=Jarcho
[arithmetic-side-effects] Detect overflowing associated constants of integers

Triggers the negation of maximum unsigned integers using associated constants. Rustc already handles `-128i8` but doesn't handle `-i8::MAX`.

At the same time, allows stuff like `-1234`.

changelog: FP: [arithmetic-side-effects] Detect overflowing associated constants of integers
2022-11-20 22:51:25 +00:00
bors
a85c8f33ff Auto merge of #9870 - koka831:unformat-unused-rounding, r=Jarcho
Keep original literal notation in suggestion

While I did some investigation of https://github.com/rust-lang/rust-clippy/issues/9866 (I couldn't reproduce it though) I found that `unused_rounding` formats as follows:

```rust
3.0_f64.round() // => 3.0f64
```

This PR makes them preserve as the original notation.

```rust
3.0_f64.round() // => 3.0_f64
```

changelog: Suggestion Enhancement: [`unused_rounding`]: The suggestion now preserves the original float literal notation
2022-11-20 22:09:25 +00:00
Sosthène Guédon
1f2f50c34e Fix many false negatives caused by autoderef 2022-11-20 17:03:53 +01:00
Sosthène Guédon
0411edfbbd Improve diagnostic for cases where autoderef is used 2022-11-20 15:49:09 +01:00
bors
d445ced166 Auto merge of #9879 - Alexendoo:allow, r=Manishearth
Fix `#[allow]` for `module_name_repetitions` & `single_component_path_imports`

Fixes #7511
Fixes #8768
Fixes #9401

`single_component_path_imports` needed some changes to the lint itself, it now buffers the found single component paths to emit in the equivalent `check_item`

changelog: Fix `#[allow(clippy::module_name_repetitions)]` and `#[allow(clippy::single_component_path_imports)]`
2022-11-20 13:17:02 +00:00
Sosthène Guédon
6178ddaded misname-getters: Fix documentation 2022-11-20 13:46:38 +01:00
Sosthène Guédon
d9993cb133 Remove error when fields use autoderef 2022-11-20 13:45:12 +01:00
Sosthène Guédon
77374a9527 Add failing test 2022-11-20 13:45:12 +01:00
Sosthène Guédon
3f1a186bd1 misnamed_getters: Trigger on unsafe with _unchecked 2022-11-20 13:45:12 +01:00
Sosthène Guédon
a867c17ab3 Improve code 2022-11-20 13:45:12 +01:00
Sosthène Guédon
3428da6e00 Fix typo missnamed -> misnamed 2022-11-20 13:45:12 +01:00
Sosthène Guédon
3e2e81b2db Fix internal warnings 2022-11-20 13:45:12 +01:00
Sosthène Guédon
5fa0e07cdf Document missname_getters 2022-11-20 13:45:12 +01:00
Sosthène Guédon
81d4590834 missnamed_getters: use all_fields iterator 2022-11-20 13:45:12 +01:00
Sosthène Guédon
ddc49966dc Fix suggestion to point to the whole method 2022-11-20 13:45:12 +01:00
Sosthène Guédon
9891af348c missnamed_getters: Match owned methods 2022-11-20 13:45:12 +01:00
Sosthène Guédon
31b83d0895 Add missnamed_getters lint 2022-11-20 13:45:11 +01:00
Alex Macleod
4d8af99365 Fix #[allow] for module_name_repetitions & single_component_path_imports 2022-11-20 12:39:19 +00:00
bors
80a4699aae Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errors
Minimal implementation of implicit deref patterns for Strings

cc `@compiler-errors` `@BoxyUwU` https://github.com/rust-lang/lang-team/issues/88 #87121

~~I forgot to add a feature gate, will do so in a minute~~ Done
2022-11-20 07:16:42 +00:00
Matthias Krüger
27c4c17684 Rollup merge of #104593 - compiler-errors:rpitit-object-safety-spans, r=fee1-dead
Improve spans for RPITIT object-safety errors

No reason why we can't point at the `impl Trait` that causes the object-safety violation.

Also [drive-by: Add is_async fn to hir::IsAsync](c4165f3a96), which touches clippy too.
2022-11-19 15:35:23 +01:00
koka
1baa6cd591
refac: grab a snip from receiver 2022-11-19 21:21:47 +09:00
Caio
e0b1463e0a Remove unused 2022-11-19 08:25:20 -03:00
Caio
98b343c5e6 [arithmetic-side-effects] Detect overflowing associated constants of integers 2022-11-19 08:22:27 -03:00
Samuel Moelius
ef5f60285f Move line_span to source.rs 2022-11-19 05:53:49 -05:00
bors
f60186f35d Auto merge of #9800 - Alexendoo:def_path_res_multiple, r=dswij
Return multiple resolutions from `def_path_res`

Changes `def_path_res` to return all the resolutions matching the path rather than the first one (with a namespace hint that covered some cases).  This would fix any issues that come up with multiple versions of the same crate being present as they all have the same crate name

It also adds resolution of `impl _ {}` items for local items, and removes struct field resolution as it didn't seem to be used anywhere

I tested it on a local crate and it worked for the multiple crate issue, but I couldn't come up with a test that worked well with `// aux-build`, maybe `// aux-crate` after https://github.com/rust-lang/rust/pull/103266 could work but I'm not sure on that either

changelog: [`disallowed_methods`], [`disallowed_types`], [`disallowed_macros`]: fix path resolution with multiple versions of the same crate
changelog: [`disallowed_methods`]: Resolve methods in `impl`s in the current crate
2022-11-19 09:05:50 +00:00
Michael Goulet
a09143866f drive-by: PolyExistentialPredicate 2022-11-19 04:04:27 +00:00
Michael Goulet
3a2eaa73f4 drive-by: Add is_async fn to hir::IsAsync 2022-11-19 02:22:24 +00:00
bors
f6d4ef9447 Auto merge of #104573 - matthiaskrgr:rollup-k36ybtp, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #101162 (Migrate rustc_resolve to use SessionDiagnostic, part # 1)
 - #103386 (Don't allow `CoerceUnsized` into `dyn*` (except for trait upcasting))
 - #103405 (Detect incorrect chaining of if and if let conditions and recover)
 - #103594 (Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets)
 - #104006 (Add variant_name function to `LangItem`)
 - #104494 (Migrate GUI test to use functions)
 - #104516 (rustdoc: clean up sidebar width CSS)
 - #104550 (fix a typo)

Failed merges:

 - #104554 (Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-18 20:26:58 +00:00
bors
bc01b2e1f4 Auto merge of #101562 - nnethercote:shrink-ast-Expr-harder, r=petrochenkov
Shrink `ast::Expr` harder

r? `@ghost`
2022-11-18 16:56:12 +00:00
bors
e144c7d1ae Auto merge of #9871 - koka831:fix/9864, r=xFrednet
Allow manual swap in const fn

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

changelog: Fix [`manual_swap`]: No longer lints in constant code
2022-11-18 16:04:18 +00:00
koka
3c86cade4e
Note about const fn
Since `std::mem::swap` is not stable as a const fn, the suggestion
would not be applicable in that cases
2022-11-19 00:28:02 +09:00
bors
d019fd9780 Auto merge of #9855 - Alexendoo:needless-borrowed-ref-extra, r=xFrednet
Extend `needless_borrowed_reference` to structs and tuples, ignore _

changelog: [`needless_borrowed_reference`]: Lint struct and tuple patterns, and patterns containing `_`

Now lints patterns like

```rust
&(ref a, ref b)
&Tuple(ref a, ref b)
&Struct { ref a, ref b }

&(ref a, _)
```
2022-11-18 14:26:50 +00:00
Matthias Krüger
8749eda8ee Rollup merge of #104006 - flip1995:lang-items-clippy, r=oli-obk
Add variant_name function to `LangItem`

Clippy has an internal lint that checks for the usage of hardcoded def paths and suggests to replace them with a lang or diagnostic item, if possible. This was implemented with a hack, by getting all the variants of the `LangItem` enum and then index into it with the position of the `LangItem` in the `items` list. This is no longer possible, because the `items` list can't be accessed anymore.

Follow up to #103603

cc `@camsteffen`
r? `@oli-obk`

This is blocking the sync between Clippy and Rust. I'm not sure if this is the best solution here, or if I should add a method `items()` to `LanguageItems` and keep the code in Clippy unchanged.
2022-11-18 14:13:37 +01:00
koka
928a158716
Allow manual swap in const fn 2022-11-18 21:51:43 +09:00
koka
921f4d317e
Keep original literal notation in suggestion 2022-11-18 21:23:16 +09:00
bors
01f40ce3bc Auto merge of #9863 - smoelius:expect-unwrap-used-typo, r=flip1995
Fix typo in `expect_used` and `unwrap_used` warning messages

"\`an Option\`" -> "an \`Option\`" and "\`a Result\`" -> "a \`Result\`".

changelog: fix typo in `expect_used` and `unwrap_used` warning messages
2022-11-18 11:49:47 +00:00
bors
dfe37f13cf Auto merge of #9850 - pheki:fix-7499-missing-ref, r=dswij
Preserve `ref` on `infallible_destructuring_match` suggestion

Fixes https://github.com/rust-lang/rust-clippy/issues/7499

changelog: [`infallible_destructuring_match`]: Preserve `ref` on suggestion
2022-11-18 09:43:51 +00:00
bors
1c9c34de17 Auto merge of #9858 - DesmondWillowbrook:never_loop, r=dswij
`never_loop`: don't emit AlwaysBreaks if it targets a block

ref: https://github.com/rust-lang/rust-clippy/pull/9837#issuecomment-1312788194

The previous fix (#9837) was too simple and ignored all break commands inside a labelled block, regardless of whether their destination was a labelled block or a loop. This fix tracks all the labelled blocks in scope to ensure that only breaks targeting loops are considered.

changelog: [`never_loop`]: prevent false negatives from `breaks` nested in labelled blocks
2022-11-18 09:31:20 +00:00
Deadbeef
a09423f8c8 Rm diagnostic item, use lang item 2022-11-18 06:16:20 +00:00
Matthias Krüger
f7535e771d Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errors
Convert predicates into Predicate in the Obligation constructor

instead of having almost all callers do that.

This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
2022-11-17 22:33:19 +01:00
Philipp Krones
82afb16179 Add variant_name function to LangItem
Clippy has an internal lint that checks for the usage of hardcoded def
paths and suggests to replace them with a lang or diagnostic item, if
possible. This was implemented with a hack, by getting all the variants
of the `LangItem` enum and then index into it with the position of the
`LangItem` in the `items` list. This is no longer possible, because the
`items` list can't be accessed anymore.
2022-11-17 20:06:25 +01:00
Samuel Moelius
00ae5e15a8 Fix typo in expect_used and unwrap_used warning messages 2022-11-17 15:02:48 +00:00