Commit graph

4742 commits

Author SHA1 Message Date
yukang
0ff6579eac fix RedundantLocals clippy caused by async and await 2023-08-02 16:32:49 +08:00
Philipp Krones
b0e64a9c09 Merge commit '5436dba826191964ac1d0dab534b7eb6d4c878f6' into clippyup 2023-07-31 23:53:53 +02:00
Matthias Krüger
f54263af58 Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
2023-07-30 14:25:08 +02:00
Maybe Waffle
0c93e30956 Mark map_or as #[must_use] 2023-07-30 10:22:23 +00:00
bors
436060f637 Auto merge of #113422 - Urgau:cast_ref_to_mut-pre-beta, r=Nilstrieb
Rename and allow `cast_ref_to_mut` lint

This PR is a small subset of https://github.com/rust-lang/rust/pull/112431, that is the renaming of the lint (`cast_ref_to_mut` -> `invalid_reference_casting`).

BUT also temporarily change the default level of the lint from deny-by-default to allow-by-default until https://github.com/rust-lang/rust/pull/112431 is merged.

r? `@Nilstrieb`
2023-07-29 07:48:44 +00:00
León Orell Valerian Liehr
4c9d68e9b8 Make Clippy understand generic const items 2023-07-28 22:21:41 +02:00
Deadbeef
39fb315396 bless clippy 2023-07-27 17:56:25 +00:00
Deadbeef
be0b4d5a9b Remove constness from ParamEnv 2023-07-27 15:50:42 +00: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
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
blyxyas
0404b6b6c2 Add sym::iter_mut + sym::as_mut_ptr 2023-07-25 23:33:08 +00:00
Oli Scherer
3fb714d828 Use a builder instead of boolean/option arguments 2023-07-25 13:51:15 +00:00
David Wood
a1473721b0 clippy: env! invocations can't be b"" literals
Signed-off-by: David Wood <david@davidtw.co>
2023-07-25 11:56:54 +01:00
lcnr
5a6c4d7d43 XSimplifiedType to SimplifiedType::X 2023-07-20 11:05:52 +02:00
Esteban Küber
cbca8f9908 On nightly, dump ICE backtraces to disk
Implement rust-lang/compiler-team#578.

When an ICE is encountered on nightly releases, the new rustc panic
handler will also write the contents of the backtrace to disk. If any
`delay_span_bug`s are encountered, their backtrace is also added to the
file. The platform and rustc version will also be collected.
2023-07-19 14:10:07 +00:00
Michael Goulet
d1e1dcb1fb Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00
Philipp Krones
2feb9a582f Another fix for incorrect_impls 2023-07-17 10:22:49 +02:00
Philipp Krones
d6d530fd0b Merge commit 'd9c24d1b1ee61f276e550b967409c9f155eac4e3' into clippyup 2023-07-17 10:22:32 +02:00
Mahdi Dibaiee
fdb2e363d3 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Urgau
50da77521e Rename cast_ref_to_mut to invalid_reference_casting (clippy side) 2023-07-13 23:01:24 +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
Urgau
103949b241 Drop uplifted clippy::fn_null_check 2023-07-10 18:12:41 +02:00
bors
1816caaa76 Auto merge of #113376 - Nilstrieb:pointer-coercions-are-not-casts-because-that-sounds-way-to-general-aaaa, r=oli-obk
Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`

It makes it sounds like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a little enum variants. Make it clear there these are only coercions and that people who see this and think "why are so many pointer related casts not in these variants" aren't insane.

This enum was added in #59987. I'm not sure whether the variant sharing is actually worth it, but this at least makes it less confusing.

r? oli-obk
2023-07-08 13:48:30 +00:00
Alex Macleod
87373d7f52 Fix failing clippy tests
Comments out the C string literals due to https://github.com/rust-lang/rust/pull/113334

Fixes https://github.com/rust-lang/rust-clippy/issues/11121
2023-07-07 18:19:08 +00:00
Nilstrieb
b5ac726ed3 Rename adjustment::PointerCast and variants using it to PointerCoercion
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related
casts, when in reality their just used to share a some enum variants. Make it clear there these
are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-07 18:17:16 +02:00
Boxy
cbe468222a Move TyCtxt::mk_x to Ty::new_x where applicable 2023-07-05 20:27:07 +01:00
Philipp Krones
cb3ecf7b79 Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup 2023-07-02 14:59:02 +02:00
bors
bb33e0343f Auto merge of #112718 - oli-obk:SIMD-destructure_mir_const, r=cjgillot
Make simd_shuffle_indices use valtrees

This removes the second-to-last user of the `destructure_mir_constant` query. So in a follow-up we can remove the query and just move the query provider function directly into pretty printing (which is the last user).

cc `@rust-lang/clippy` there's a small functional change, but I think it is correct?
2023-07-02 07:43:36 +00:00
Michael Goulet
716c552632 Migrate predicates_of and caller_bounds to Clause 2023-06-26 23:12:03 +00:00
bors
a9e0bbb931 Auto merge of #112887 - WaffleLapkin:become_unuwuable_in_hir, r=compiler-errors,Nilstrieb
`hir`: Add `Become` expression kind (explicit tail calls experiment)

This adds `hir::ExprKind::Become` alongside ast lowering. During hir-thir lowering we currently lower `become` as `return`, so that we can partially test `become` without ICEing.

cc `@scottmcm`
r? `@Nilstrieb`
2023-06-26 13:51:04 +00:00
Oli Scherer
7bd8ab77e5 Make simd_shuffle_indices use valtrees 2023-06-26 09:34:52 +00:00
Maybe Waffle
555bd985d2 Support hir::ExprKind::Become in clippy 2023-06-26 08:56:32 +00:00
Michael Goulet
533a819115 Migrate item_bounds to ty::Clause 2023-06-22 18:34:23 +00:00
bors
a2b99d8174 Auto merge of #112877 - Nilstrieb:rollup-5g5hegl, r=Nilstrieb
Rollup of 6 pull requests

Successful merges:

 - #112632 (Implement PartialOrd for `Vec`s over different allocators)
 - #112759 (Make closure_saved_names_of_captured_variables a query. )
 - #112772 (Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`)
 - #112790 (Syntactically accept `become` expressions (explicit tail calls experiment))
 - #112830 (More codegen cleanups)
 - #112844 (Add retag in MIR transform: `Adt` for `Unique` may contain a reference)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-21 08:00:23 +00:00
bors
70c2d0cfe5 Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieu
Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata

FCP completed in https://github.com/rust-lang/rust/issues/103763#issuecomment-1362267967

Closes #103763
2023-06-21 05:13:39 +00:00
Michael Goulet
b2c7ce8908 s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
Oli Scherer
5777494f99 Add AliasKind::Weak for type aliases.
Only use it when the type alias contains an opaque type.

Also does wf-checking on such type aliases.
2023-06-16 19:39:48 +00:00
Urgau
edb3266b91 Drop uplifted clippy:cmp_nan 2023-06-10 11:13:01 +02:00
bors
b356491a31 Auto merge of #111530 - Urgau:uplift_undropped_manually_drops, r=compiler-errors
Uplift `clippy::undropped_manually_drops` lint

This PR aims at uplifting the `clippy::undropped_manually_drops` lint.

## `undropped_manually_drops`

(warn-by-default)

The `undropped_manually_drops` lint check for calls to `std::mem::drop` with a value of `std::mem::ManuallyDrop` which doesn't drop.

### Example

```rust
struct S;
drop(std::mem::ManuallyDrop::new(S));
```

### Explanation

`ManuallyDrop` does not drop it's inner value so calling `std::mem::drop` will not drop the inner value of the `ManuallyDrop` either.

-----

Mostly followed the instructions for uplifting an clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler

-----

For Clippy:

changelog: Moves: Uplifted `clippy::undropped_manually_drops` into rustc
2023-06-09 12:44:23 +00:00
Urgau
f47e9156a4 Drop uplifted clippy::undropped_manually_drops 2023-06-08 11:41:34 +02:00
Andrew Xie
737cba0c37 Whoops, submodule change was actually valid - undoing fixup 2023-06-08 01:05:38 -04:00
Andrew Xie
ecd6afaa12 fixup! Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:40:29 -04:00
Andrew Xie
f2f342adb4 Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:38:50 -04:00
Matthias Krüger
5a8ec9bbe7 Rollup merge of #112165 - fee1-dead-contrib:rn-defualtness, r=compiler-errors
Rename `impl_defaultness` to `defaultness`

Since this isn't just about the `impl`.
2023-06-02 18:12:45 +02:00
Philipp Krones
e6dc0efc00 Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup 2023-06-02 11:41:57 +02:00
Deadbeef
c11573d78c Rename impl_defaultness to defaultness 2023-06-01 06:14:06 +00:00
Urgau
1a5db18b11 Drop uplifted clippy::cast_ref_to_mut 2023-05-31 13:42:53 +02:00
Nilstrieb
a3ff2b92e6 Rollup merge of #112060 - lcnr:early-binder, r=jackh726
`EarlyBinder::new` -> `EarlyBinder::bind`

for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR.

r? `@jackh726` `@kylematsuda`
2023-05-30 12:57:40 +02:00
Nilstrieb
faf2e5db0c Rollup merge of #111543 - Urgau:uplift_invalid_utf8_in_unchecked, r=WaffleLapkin
Uplift `clippy::invalid_utf8_in_unchecked` lint

This PR aims at uplifting the `clippy::invalid_utf8_in_unchecked` lint into two lints.

## `invalid_from_utf8_unchecked`

(deny-by-default)

The `invalid_from_utf8_unchecked` lint checks for calls to `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut` with an invalid UTF-8 literal.

### Example

```rust
unsafe {
    std::str::from_utf8_unchecked(b"cl\x82ippy");
}
```

### Explanation

Creating such a `str` would result in undefined behavior as per documentation for `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut`.

## `invalid_from_utf8`

(warn-by-default)

The `invalid_from_utf8` lint checks for calls to `std::str::from_utf8` and `std::str::from_utf8_mut` with an invalid UTF-8 literal.

### Example

```rust
std::str::from_utf8(b"ru\x82st");
```

### Explanation

Trying to create such a `str` would always return an error as per documentation for `std::str::from_utf8` and `std::str::from_utf8_mut`.

-----

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

-----

For Clippy:

changelog: Moves: Uplifted `clippy::invalid_utf8_in_unchecked` into rustc
2023-05-30 12:57:38 +02:00
lcnr
739530a03c EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00