rust/tests/ui/traits/new-solver
bors 077fc26f0a Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwco
Uplift `clippy::{drop,forget}_{ref,copy}` lints

This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints.

Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted.

## `drop_ref` and `forget_ref`

The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value.

### Example

```rust
let mut lock_guard = mutex.lock();
std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
// still locked
operation_that_requires_mutex_to_be_unlocked();
```

### Explanation

Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended.

## `drop_copy` and `forget_copy`

The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait.

### Example

```rust
let x: i32 = 42; // i32 implements Copy
std::mem::forget(x) // A copy of x is passed to the function, leaving the
                    // original unaffected
```

### Explanation

Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation.

-----

Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-12 12:04:32 +00:00
..
coherence new solver cleanup + coherence 2023-03-21 16:27:25 +01:00
alias_eq_cant_be_furthur_normalized.rs Add tests 2023-02-10 14:56:28 +00:00
alias_eq_dont_use_normalizes_to_if_substs_eq.rs prioritize param-env candidates 2023-04-10 09:16:33 +02:00
alias_eq_dont_use_normalizes_to_if_substs_eq.stderr Add tests 2023-02-10 14:56:28 +00:00
alias_eq_simple.rs Add tests 2023-02-10 14:56:28 +00:00
alias_eq_substs_eq_not_intercrate.rs Add tests 2023-02-10 14:56:28 +00:00
alias_eq_substs_eq_not_intercrate.stderr Add tests 2023-02-10 14:56:28 +00:00
alias-bound-unsound.rs Make alias bounds sound in the new solver 2023-05-09 20:37:50 +00:00
alias-bound-unsound.stderr Make alias bounds sound in the new solver 2023-05-09 20:37:50 +00:00
alias-eq-in-canonical-response.rs Return nested obligations from canonical response var unification 2023-03-23 19:00:04 +00:00
alias-sub.rs Include relation direction in AliasEq predicate 2023-03-23 05:56:27 +00:00
async.fail.stderr
async.rs
auto-with-drop_tracking_mir.fail.stderr Adjust tests for new drop and forget lints 2023-05-10 19:36:02 +02:00
auto-with-drop_tracking_mir.rs Adjust tests for new drop and forget lints 2023-05-10 19:36:02 +02:00
borrowck-error.rs Clone region var origins instead of taking in borrowck 2023-04-21 00:31:43 +00:00
borrowck-error.stderr Clone region var origins instead of taking in borrowck 2023-04-21 00:31:43 +00:00
builtin-fn-must-return-sized.rs Check that built-in callable types validate their output type is Sized (in new solver) 2023-02-18 19:32:58 +00:00
builtin-fn-must-return-sized.stderr Check that built-in callable types validate their output type is Sized (in new solver) 2023-02-18 19:32:58 +00:00
canonical-int-var-eq-in-response.rs Drive-by: Add -Ztrait-solver=next to canonical int var test 2023-03-22 18:26:33 +00:00
canonical-ty-var-eq-in-response.rs Canonicalize the ROOT VAR 2023-03-07 17:11:35 +00:00
cast-checks-handling-projections.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
closure-inference-guidance.rs Closures always implement FnOnce in new solver 2023-03-30 15:11:42 +00:00
const-param-placeholder.fail.stderr Don't ICE on placeholder consts in deep reject 2023-03-29 23:28:44 +00:00
const-param-placeholder.rs Don't ICE on placeholder consts in deep reject 2023-03-29 23:28:44 +00:00
deduce-ty-from-object.rs Canonicalize the ROOT VAR 2023-03-07 17:11:35 +00:00
destruct.rs Implement non-const Destruct trait in new solver 2023-03-22 18:22:27 +00:00
dont-elaborate-for-projections.rs Do not consider elaborated projection predicates for objects in new solver 2023-03-29 16:13:05 +00:00
elaborate-item-bounds.rs Use elaborated item bounds for alias types 2023-02-09 17:16:47 +00:00
equating-projection-cyclically.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
equating-projection-cyclically.stderr Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
exponential-trait-goals.rs Clear response values for overflow in new solver 2023-04-26 21:54:30 +00:00
exponential-trait-goals.stderr Clear response values for overflow in new solver 2023-04-26 21:54:30 +00:00
float-canonical.rs canonicalize float var as float in new solver 2023-03-30 01:15:37 +00:00
fn-trait-closure.rs
fn-trait.rs Also check function items' signatures for Fn* trait compatibility 2023-03-21 11:50:14 +00:00
fn-trait.stderr Also check function items' signatures for Fn* trait compatibility 2023-03-21 11:50:14 +00:00
generator.fail.stderr
generator.rs
higher-ranked-dyn-bounds.rs Make higher-ranked projections in object types work in new solver 2023-02-24 02:48:44 +00:00
int-var-alias-eq.rs vars are ? 2023-04-25 19:53:09 +00:00
int-var-is-send.rs Stall auto-trait assembly for int/float vars in new solver 2023-04-10 15:54:14 +00:00
iter-filter-projection.rs Add test for uniquifying regions 2023-04-14 03:22:12 +00:00
lazy-nested-obligations-1.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
lazy-nested-obligations-2.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
lazy-nested-obligations-3.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
more-object-bound.rs Do not consider elaborated projection predicates for objects in new solver 2023-03-29 16:13:05 +00:00
more-object-bound.stderr Do not consider elaborated projection predicates for objects in new solver 2023-03-29 16:13:05 +00:00
negative-coherence-bounds.rs Negative coherence test 2023-04-25 05:02:39 +00:00
negative-coherence-bounds.stderr Negative coherence test 2023-04-25 05:02:39 +00:00
nested-alias-bound.rs Make alias bounds sound in the new solver 2023-05-09 20:37:50 +00:00
nested-obligations-with-bound-vars-gat.rs Add a test that used to take forever to compile 2023-03-13 16:34:16 +00:00
normalize-param-env-1.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
normalize-param-env-2.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
normalize-param-env-3.rs Commit some tests for the new solver + lazy norm 2023-03-11 23:16:46 +00:00
normalizes_to_ignores_unnormalizable_candidate.rs Add tests 2023-02-10 14:56:28 +00:00
normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr Add tests 2023-02-10 14:56:28 +00:00
object-unsafety.rs Check object's supertrait and associated type bounds in new solver 2023-02-24 02:45:05 +00:00
object-unsafety.stderr Check object's supertrait and associated type bounds in new solver 2023-02-24 02:45:05 +00:00
param-candidate-doesnt-shadow-project.rs Add a couple random projection tests 2023-02-10 18:14:09 +00:00
param-discr-kind.rs Don't ICE on DiscriminantKind projection in new solver 2023-03-30 00:53:16 +00:00
pointee.rs Check pointee metadata correctly in ui test 2023-03-30 00:53:17 +00:00
pointer-like.rs Enforce that PointerLike requires a pointer-like ABI 2023-04-08 21:11:16 +00:00
pointer-like.stderr Enforce that PointerLike requires a pointer-like ABI 2023-04-08 21:11:16 +00:00
prefer-candidate-no-constraints.rs prioritize param-env candidates 2023-04-10 09:16:33 +02:00
prefer-param-env-on-ambiguity.rs prioritize param-env candidates 2023-04-10 09:16:33 +02:00
projection-discr-kind.rs Don't ICE on DiscriminantKind projection in new solver 2023-03-30 00:53:16 +00:00
projection-discr-kind.stderr Don't ICE on DiscriminantKind projection in new solver 2023-03-30 00:53:16 +00:00
provisional-result-done.rs Multiple candidates with same response is not ambiguous 2023-02-10 00:35:25 +00:00
recursive-self-normalization-2.rs Report overflows gracefully with new solver 2023-04-10 16:36:30 +00:00
recursive-self-normalization-2.stderr Report overflows gracefully with new solver 2023-04-10 16:36:30 +00:00
recursive-self-normalization.rs Report overflows gracefully with new solver 2023-04-10 16:36:30 +00:00
recursive-self-normalization.stderr Report overflows gracefully with new solver 2023-04-10 16:36:30 +00:00
runaway-impl-candidate-selection.rs Treat projections with infer as placeholder during fast reject in new solver 2023-03-13 16:34:16 +00:00
runaway-impl-candidate-selection.stderr Treat projections with infer as placeholder during fast reject in new solver 2023-03-13 16:34:16 +00:00
specialization-transmute.rs transmute test 2023-03-26 00:03:14 +00:00
specialization-transmute.stderr transmute test 2023-03-26 00:03:14 +00:00
specialization-unconstrained.rs Still-further-specializable projections are ambiguous 2023-03-25 23:51:08 +00:00
specialization-unconstrained.stderr Still-further-specializable projections are ambiguous 2023-03-25 23:51:08 +00:00
stall-num-var-auto-trait.fallback.stderr Stall auto-trait assembly for int/float vars in new solver 2023-04-10 15:54:14 +00:00
stall-num-var-auto-trait.rs Stall auto-trait assembly for int/float vars in new solver 2023-04-10 15:54:14 +00:00
temporary-ambiguity.rs Adjust tests for new drop and forget lints 2023-05-10 19:36:02 +02:00
try-example.rs Commit some new solver tests 2023-02-27 05:23:26 +00:00
two-projection-param-candidates-are-ambiguous.rs vars are ? 2023-04-25 19:53:09 +00:00
two-projection-param-candidates-are-ambiguous.stderr Add a couple random projection tests 2023-02-10 18:14:09 +00:00
unsafe-auto-trait-impl.rs Disqualify auto-trait builtin impl in new solver if impl exists 2023-02-09 17:23:50 +00:00
unsize-good.rs
upcast-right-substs.rs Trait upcasting support in new solver 2023-01-30 19:11:01 +00:00
upcast-wrong-substs.rs Trait upcasting support in new solver 2023-01-30 19:11:01 +00:00
upcast-wrong-substs.stderr Trait upcasting support in new solver 2023-01-30 19:11:01 +00:00