summaryrefslogtreecommitdiff
path: root/tests/ui/closures
Commit message (Collapse)AuthorAgeFilesLines
* Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors2023-05-124-1/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
| * Adjust tests for new drop and forget lintsUrgau2023-05-104-1/+5
| |
* | Rollup merge of #108705 - clubby789:refutable-let-closure-borrow, r=cjgillotMatthias Krüger2023-05-112-0/+136
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | Prevent ICE with broken borrow in closure r? `@Nilstrieb` Fixes #108683 This solution isn't ideal, I'm hoping to find a way to continue compilation without ICEing.
| * | Bail out of MIR construction if `check_match` failsclubby7892023-04-302-0/+136
| | |
* | | Rollup merge of #111021 - c410-f3r:dqewdas, r=petrochenkovMatthias Krüger2023-05-091-0/+18
|\ \ \ | |_|/ |/| | | | | | | | | | | Move some tests r? ``@petrochenkov``
| * | Move testsCaio2023-05-081-0/+18
| | |
* | | tweak "make mut" spans when assigning to localsEzra Shaw2023-05-051-1/+1
|/ /
* | Test precise capture with a multi-variant enum and exhaustive patternsTomasz Miąsko2023-04-301-0/+21
|/ | | | | | Add test checking that it is possible to capture fields of a multi-variant enum, when remaining variants are visibly uninhabited (under the `exhaustive_patterns` feature gate).
* improve error notes for packed struct reference diagnosticbindsdev2023-04-281-1/+2
|
* vars are ?Michael Goulet2023-04-255-9/+9
|
* Rollup merge of #110480 - whtahy:105107/known-bug-tests-for-unsound-issues, ↵Yuki Okushi2023-04-251-0/+15
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=jackh726 Add `known-bug` tests for 11 unsound issues r? ``@jackh726`` Should tests for other issues be in separate PRs? Thanks. Edit: Partially addresses #105107. This PR adds `known-bug` tests for 11 unsound issues: - #25860 - #49206 - #57893 - #84366 - #84533 - #84591 - #85099 - #98117 - #100041 - #100051 - #104005
| * add known-bug test for unsound issue 84366whtahy2023-04-221-0/+15
| |
* | Run `check_match` and `check_liveness` when MIR is built instead of having ↵Oli Scherer2023-04-211-14/+14
|/ | | | an explicit phase for them
* Broken testsMichael Goulet2023-04-111-0/+14
|
* Fix subslice capture in closureclubby7892023-03-272-0/+39
|
* Return equal for two identical projectionsyukang2023-03-212-0/+41
|
* Remove the `capture_disjoint_fields` featureclubby7892023-02-281-4/+1
|
* Add addl testMichael Goulet2023-02-182-0/+24
|
* Move late-bound arg type checks to resolve_bound_varsMichael Goulet2023-02-184-0/+48
|
* Adjust tracking issue for non_lifetime_bindersMichael Goulet2023-02-182-2/+2
|
* Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillotMatthias Krüger2023-02-172-2/+10
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Implement partial support for non-lifetime binders This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed. Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged. Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`) cc rust-lang/types-team#81 r? `@ghost`
| * Add feature gate for non_lifetime_bindersMichael Goulet2023-02-162-2/+10
| |
* | Fix unintentional UB in ui testsBen Kimock2023-02-156-9/+9
|/
* make unaligned_reference a hard errorRalf Jung2023-01-312-19/+2
|
* Modify primary span label for E0308Esteban Küber2023-01-301-1/+1
| | | | The previous output was unintuitive to users.
* Rollup merge of #106897 - estebank:issue-99430, r=davidtwcoMatthias Krüger2023-01-254-15/+15
|\ | | | | | | | | | | Tweak E0597 CC #99430
| * Tweak E0597Esteban Küber2023-01-154-15/+15
| | | | | | | | CC #99430
* | Tweak "borrow closure argument" suggestionEsteban Küber2023-01-191-4/+6
|/ | | | Fix #45727.
* Emit a hint for bad call return types due to generic argumentsRobin Schroer2023-01-132-0/+28
| | | | | | | | | | | | | | | | | | | | | | When the return type of a function call depends on the type of an argument, e.g. ``` fn foo<T>(x: T) -> T { x } ``` and the expected type is set due to either an explicitly typed binding, or because the call to the function is in a tail position without semicolon, the current error implies that the argument in the call has the wrong type. This new hint highlights that the expected type doesn't match the returned type, which matches the argument type, and that that's why we're flagging the argument type. Fixes #43608.
* Move /src/test to /testsAlbert Larsan2023-01-11352-0/+13446