Commit Graph

13379 Commits

Author SHA1 Message Date
Jason Newcomb
c02dff7167 Fix transmute_undefined_repr when converting between a pointer and a type containing a pointer 2022-02-18 15:01:58 -05:00
bors
73367f8768 Auto merge of #8381 - Jarcho:cast_possible_truncation_542, r=Manishearth
Lint enum-to-int casts with `cast_possible_truncation`

fixes: #542

~~This will not lint casting a specific variant to an integer. That really should be a new lint as it's definitely a truncation (other than `isize`/`usize` values).~~

changelog: Lint enum-to-int casts with `cast_possible_truncation`
changelog: New lint `cast_enum_truncation`
2022-02-18 19:31:10 +00:00
Jason Newcomb
88ecdd0804 Extract some util functions 2022-02-18 09:45:11 -05:00
Jason Newcomb
90bb7a3476 New lint cast_enum_truncation 2022-02-18 09:16:17 -05:00
Jason Newcomb
8a466454ab Lint enum-to-int casts with cast_possible_truncation 2022-02-18 09:11:15 -05:00
bors
02f3c17593 Auto merge of #8419 - flip1995:await_parking_alot, r=llogiq
Fix `await_holding_lock` not linting `parking_lot` Mutex/RwLock

This adds tests for `RwLock` and `parking_lot::{Mutex, RwLock}`, which were added before in 2dc8c083f5, but never tested in UI tests. I noticed this while reading [fasterthanli.me](https://fasterthanli.me/articles/a-rust-match-made-in-hell) latest blog post, complaining that Clippy doesn't catch this for `parking_lot`. (Too many people read his blog, he's too powerful)

Some more things:
- Adds a test for #6446
- Improves the lint message

changelog: [`await_holding_lock`]: Now also lints for `parking_lot::{Mutex, RwLock}`
2022-02-18 10:55:05 +00:00
bors
76f91b6f5a Auto merge of #8442 - rsmantini:issue-8120-fix, r=Manishearth
trigger  `ptr_as_ptr` inside macros

This PR makes `ptr_as_ptr` trigger inside macros

Fixes issue #8120

changelog: ``[`ptr_as_ptr`]`` is now triggered inside macros

r? `@llogiq`
2022-02-17 22:57:23 +00:00
Rodrigo Mantini
aaeeed6a59 trigger ptr_as_ptr inside macros 2022-02-17 20:16:14 +01:00
flip1995
ea0ce7bb76
Move await_holding_* lints to suspicious and improve doc
Even though the FP for that the lints were moved to pedantic isn't fixed
yet, running the lintcheck tool over the most popular 279 crates didn't
trigger this lint once. I would say that this lint is valuable enough,
despite the known FP, to be warn-by-default. Especially since a pretty
nice workaround exists.
2022-02-17 18:03:17 +01:00
flip1995
c5709419b1
Add test for drop-before-await FP 2022-02-17 18:03:13 +01:00
flip1995
c4944fb60d
Actually lint parking_lot in await_holding_lock
This adapts the paths for the parking_lot mutex guards, so that
parking_lot mutexes and RwLocks actually get linted. This is now also
tested.
2022-02-17 18:02:31 +01:00
flip1995
cdf9a28006
Improve lint message of await_holding_*
Improves the message of the lints await_holding_lock and
await_holding_refcell_ref. Now also actually tests RwLock.
2022-02-17 18:00:40 +01:00
bors
668b3e47f9 Auto merge of #8218 - Jarcho:redundant_slicing_deref, r=camsteffen
Improve `redundant_slicing` lint

fixes #7972
fixes #7257

This can supersede #7976

changelog: Fix suggestion for `redundant_slicing` when re-borrowing for a method call
changelog: New lint `deref_as_slicing`
2022-02-17 16:08:45 +00:00
bors
7ee2081fb6 Auto merge of #8441 - Jarcho:needless_borrow_temp, r=flip1995
Don't lint `needless_borrow` in method receiver positions

fixes #8408
fixes #8407
fixes #8391
fixes #8367
fixes #8380

This is a temporary fix for `needless_borrow`. The proper fix is included in #8355.

This should probably be merged into rustc before beta branches on Friday. This issue has been reported six or seven times in the past couple of weeks.

changelog: Fix various issues with `needless_borrow` n´. Note to changelog writer: those issues might have been introduced in this release cycle, so this might not matter in the changelog.
2022-02-17 15:51:30 +00:00
bors
a4cf91b9c8 Auto merge of #8433 - hellow554:update_default_trait, r=flip1995
Don't lint Default::default if it is the udpate syntax base

changelog: Don't lint `Default::default` it is part of the update syntax

Current clippy warns about this:

```
warning: calling `Foo::default()` is more clear than this expression
  --> src/main.rs:12:11
   |
12 |         ..Default::default()
   |           ^^^^^^^^^^^^^^^^^^ help: try: `Foo::default()`
   |
```

With these changes, it will not lint that particular expression anymore.
2022-02-17 09:13:30 +00:00
Marcel Hellwig
504f3af70e Don't lint Default::default if it is the udpate syntax base
An Update Syntax looks like this:

   Foo {
      a: 3,
      ..Default::default()
    }

Don't lint `Default::default` here
2022-02-17 10:04:25 +01:00
Jason Newcomb
7724d6773d Move some cases from redundant_slicing to deref_by_slicing 2022-02-17 00:02:33 -05:00
Jason Newcomb
113ac6e15e Split off new lint deref_by_slicing from redundant_slicing 2022-02-17 00:02:26 -05:00
Jason Newcomb
4bdc97c4a6 Account for auto-borrows and precedence in redundant_slicing lint 2022-02-16 23:52:23 -05:00
Jason Newcomb
faeeef3b9c Improve redundant_slicing lint
* Lint when slicing triggers auto-deref
* Lint when slicing returns the same type as dereferencing
2022-02-16 23:52:23 -05:00
Jason Newcomb
a135b52102 Don't lint needless_borrow in method receiver positions 2022-02-16 23:14:39 -05:00
bors
b34cd79c0c Auto merge of #8188 - jamesmcm:recursive_display_impl, r=camsteffen
new lint: `recursive_format_impl`

The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug inside any format string in the same impl
The to_string_in_display check is kept as is - like in the format_in_format_args lint

This is my first contribution so please check it for better / more idiomatic checks + error messages. Note the format macro paths are shared with the `format_in_format_args` lint - maybe those could be moved to clippy utils too.

This relates to issues #2691 and #7830

------

changelog: Renamed `to_string_in_display` lint to [`recursive_format_impl`] with new check for any use of self as Display or Debug inside the same format trait impl.
2022-02-16 22:01:49 +00:00
James McMurray
b162b11abc Add recursive_format_impl lint
The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug
inside any format string in the same impl
The to_string_in_display check is kept as is - like in the
format_in_format_args lint

For now only Display and Debug are checked
This could also be extended to other Format traits (Binary, etc.)
2022-02-14 18:49:51 +01:00
bors
4931cab709 Auto merge of #8425 - Jarcho:transmute_8417, r=giraffate
Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs

Fixes: #8417

The description has also been made more precise.

changelog: Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs
changelog: Move `transmute_undefined_repr` back to `correctness`
2022-02-14 06:58:51 +00:00
bors
41c7004cea Auto merge of #8427 - Jarcho:merge_cargo_passes, r=llogiq
Merge cargo lints

changelog: None
2022-02-14 06:14:02 +00:00
bors
083697014c Auto merge of #8429 - nsunderland1:master, r=llogiq
Document `pub` requirement for `new_without_default` lint

fixes #8415

Also adds some UI tests that ensure that `pub` is required on both the struct _and_ the field. The only thing I'm not sure about is that the lint actually [checks](https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/new_without_default.rs#L102) if `new` is _reachable_, not _public_. To the best of my understanding, both the struct and the method need to be public for the method to be reachable for external crates (I certainly didn't manage to craft a counterexample).

changelog: Document `pub` requirement for ``[`new_without_default`]`` lint.
2022-02-14 05:55:34 +00:00
nsunderland1
78c2e0bfe9 Document pub requirement for new_without_default lint 2022-02-13 17:07:14 -08:00
Jason Newcomb
eed7e9f618 Merge cargo lints 2022-02-13 17:36:33 -05:00
Jason Newcomb
662df33e97 Fix transmute_undefined_repr with single field #[repr(C)] structs 2022-02-13 13:22:17 -05:00
bors
c37d6eed06 Auto merge of #8421 - Alexendoo:paths, r=llogiq
Replace a few paths with diagnostic items

A fairly small change towards #5393

changelog: none
2022-02-12 17:24:57 +00:00
Alex Macleod
e2dc8ca080 Replace a few paths with diagnostic items 2022-02-12 11:44:28 +00:00
bors
5707491b18 Auto merge of #8418 - dtolnay-contrib:transmuteundefinedrepr, r=llogiq
Downgrade transmute_undefined_repr to nursery

Reason: #8417. I am skeptical of this lint but maybe there is a narrower subset of types on which it is useful, so keeping it for now but moving to nursery for further development.

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Remove [`transmute_undefined_repr`] from default set of enabled lints
2022-02-12 07:22:13 +00:00
David Tolnay
79644069f0
Downgrade transmute_undefined_repr lint to nursery 2022-02-11 19:40:07 -08:00
bors
96c73c5923 Auto merge of #8411 - Alexendoo:dbg_macro, r=flip1995
Migrate `dbg_macro` to late pass

changelog: Make `dbg_macro` work with crate level attributes and inside macro calls

One down for #6610, fixes #7275

Also fixes #7274, and adds parenthesis around the suggestion for `dbg!(1, 2, 3)` as it expands to a tuple
2022-02-11 16:39:00 +00:00
Alex Macleod
41d7c7e059 Migrate dbg_macro to late pass 2022-02-11 15:56:10 +00:00
bors
57b3c4b90f Auto merge of #8409 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-02-10 17:14:39 +00:00
flip1995
49b9f9247b
Bump nightly version -> 2022-02-10 2022-02-10 18:11:49 +01:00
flip1995
0775c06d32
Merge remote-tracking branch 'upstream/master' into rustup 2022-02-10 18:11:27 +01:00
bors
6966a42c1a Auto merge of #8404 - camsteffen:rm-ui-test, r=flip1995
Factor out ui_test suite

changelog: none
2022-02-09 09:09:58 +00:00
Yuki Okushi
5044e3769e Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
Remove defaultness from ImplItem.

This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-09 14:12:22 +09:00
Cameron Steffen
88fd090531 Factor out ui_test suite 2022-02-08 15:11:48 -06:00
bors
caeebd6b09 Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
Support `cargo dev bless` for tests with revisions

changelog: internal: Support `cargo dev bless` for tests with revisions

Previously bless wouldn't pick up the saved stderr from `target/debug/tests/manual_assert.stage-id.edition2021.stderr` or `target/debug/tests/manual_assert.stage-id.edition2018.stderr` due to there being multiple revisions of the test output

This tweaks compile-test so the built files end up in e.g. `target/debug/tests/ui`, `target/debug/tests/ui-cargo` rather than share the `tests` dir. `cargo dev bless` then uses that to update all the `.stdout/stdout/fixed` files it can find

Also removes an empty file I found, and the logic to remove empty outputs as compiletest doesn't produce empty `.stdout/stderr` files
2022-02-08 20:50:41 +00:00
bors
2590701b2a Auto merge of #8400 - Jarcho:split_matches, r=Manishearth
Split matches

Part of #6680

changelog: None
2022-02-07 20:10:07 +00:00
Jason Newcomb
c65894cf1a Split out wild_in_or_pats 2022-02-07 13:00:19 -05:00
Jason Newcomb
aa3af30dee Split out rest_pat_in_fully_bound_struct 2022-02-07 12:57:02 -05:00
Jason Newcomb
6477923323 Split out infalliable_detructuring_match 2022-02-07 12:28:57 -05:00
Jason Newcomb
fb1093c561 Split out match_ref_pats 2022-02-07 12:22:27 -05:00
Jason Newcomb
1da26c8a70 Split out match_single_binding 2022-02-07 12:22:27 -05:00
Jason Newcomb
bccf06f601 Split out match_as_ref 2022-02-07 12:22:26 -05:00
Jason Newcomb
75923dff5b Split out wildcard_enum_match_arm and match_wildcard_for_single_variants 2022-02-07 12:22:26 -05:00