about summary refs log tree commit diff
path: root/src/test/ui/closures
AgeCommit message (Collapse)AuthorLines
2021-08-16Update test output.Mara Bos-152/+44
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-6/+3
2021-08-14Only compute place if upvars can be resolvedRoxane-0/+54
2021-08-13Update comment and fix fmtRoxane-4/+4
2021-08-13Update tests for new closure migration lint wording.Mara Bos-280/+280
2021-08-13Auto merge of #87956 - m-ou-se:closure-migration-macro-body, r=Aaron1011bors-0/+56
Fix closure migration suggestion when the body is a macro. Fixes https://github.com/rust-lang/rust/issues/87955 Before: ``` warning: changes to closure capture in Rust 2021 will affect drop order --> src/main.rs:5:13 | 5 | let _ = || panic!(a.0); | ^^^^^^^^^^---^ | | | in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0` 6 | } | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure | help: add a dummy let to cause `a` to be fully captured | 20~ ($msg:expr $(,)?) => ({ let _ = &a; 21+ $crate::rt::begin_panic($msg) 22~ }), | ``` After: ``` warning: changes to closure capture in Rust 2021 will affect drop order --> src/main.rs:5:13 | 5 | let _ = || panic!(a.0); | ^^^^^^^^^^---^ | | | in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0` 6 | } | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure | help: add a dummy let to cause `a` to be fully captured | 5 | let _ = || { let _ = &a; panic!(a.0) }; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
2021-08-12Add missing multi variant casesRoxane-0/+63
2021-08-12Add test for closure migration with a macro body.Mara Bos-0/+56
2021-08-12Update test output.Mara Bos-81/+108
2021-08-11Modify structured suggestion outputEsteban Küber-191/+191
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-2/+2
2021-08-03bless `expect-region-supply-region-2` test under poloniusRémy Rakic-0/+37
Polonius also emits the error that NLL doesn't get a chance to: see comment "Borrowck doesn't get a chance to run, but if it did it should error here."
2021-08-03delete expectations for `expect-region-supply-region`Rémy Rakic-56/+0
The error output is now the same as the others, no need to bless anything.
2021-07-312229: Handle MutBorrow/UniqueImmBorrow betterAman Arora-16/+16
We only want to use UniqueImmBorrow when the capture place is truncated and we drop Deref of a MutRef. r? @nikomatsakis
2021-07-30Auto merge of #86754 - estebank:use-multispans-more, r=varkorbors-2/+2
Use `multipart_suggestions` more Built on top of #86532
2021-07-30Use multispan suggestions more oftenEsteban Küber-2/+2
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-28fix nitRoxane-1/+1
2021-07-28Range PatKind implies discr should be readRoxane-0/+14
2021-07-262229: Don't capture preicese paths on top of a unionAman Arora-0/+90
- Accessing fields of a union require unsafe block - As part of 2229 we don't allow precision where we need an unsafe block to capture. Fixes: #87378 r? @nikomatsakis
2021-07-18When pretty printing, name placeholders as bound regionsjackh726-1/+1
2021-07-16Rollup merge of #87161 - sexxi-goose:fix-issue-87097, r=nikomatsakisGuillaume Gomez-0/+68
RFC2229: Use the correct place type Closes https://github.com/rust-lang/rust/issues/87097 The ICE occurred because instead of looking at the type of the place after all the projections are applied, we instead looked at the `base_ty` of the Place to decide whether a discriminant should be read of not. This lead to two issues: 1. the kind of the type is not necessarily `Adt` since we only look at the `base_ty`, it could be instead `Ref` for example 2. if the kind of the type is `Adt` you could still be looking at the wrong variant to make a decision on whether the discriminant should be read or not r? `@nikomatsakis`
2021-07-15Get the right place typeRoxane-0/+68
2021-07-14Add test for copy type in move closureAman Arora-1/+62
2021-07-11Auto merge of #86995 - sexxi-goose:rewrite, r=nikomatsakisbors-56/+142
2229: Rewrite/Refactor Closure Capture Analaysis While handling all the differnet edge cases the code for the captur analysis got pretty compicated. Looking at the overall picture of the edge cases the rules can still be layed out simply. Alogithm: https://hackmd.io/D3I_gwvuT-SPnJ22tgJumw r? `@nikomatsakis` Closes https://github.com/rust-lang/project-rfc-2229/issues/52 Implementation part of https://github.com/rust-lang/project-rfc-2229/issues/53
2021-07-09Ensure deterministic ordering for diagnosticsRoxane-2/+2
2021-07-09Address commentsRoxane-10/+10
2021-07-09Handle multi diagnosticsRoxane-8/+448
2021-07-09Fix wordingRoxane-379/+235
2021-07-09Add note clarifying why a closure no longer implements a traitRoxane-10/+30
2021-07-09Add note pointing to where a closure and it's captured variables are droppedRoxane-30/+333
2021-07-09Update error messageRoxane-32/+32
2021-07-09Add note on why the variable is not fully capturedRoxane-44/+166
2021-07-09Add more testsAman Arora-1/+105
2021-07-09Move optimization to the central processing functionAman Arora-6/+6
2021-07-09Rewrite closure capture analysisAman Arora-51/+33
2021-07-09Auto merge of #86869 - sexxi-goose:rfc2229-migration-capture-kind, ↵bors-0/+13
r=nikomatsakis Account for capture kind in auto traits migration Modifies the current auto traits migration for RFC2229 so it takes into account capture kind Closes https://github.com/rust-lang/project-rfc-2229/issues/51 r? `@nikomatsakis`
2021-07-09Auto merge of #86701 - sexxi-goose:optimization, r=nikomatsakisbors-10/+107
2229: Reduce the size of closures with `capture_disjoint_fields` One key observation while going over the closure size profile of rustc was that we are disjointly capturing one or more fields starting at an immutable reference. Disjoint capture over immutable reference doesn't add too much value because the fields can either be borrowed immutably or copied. One possible edge case of the optimization is when a fields of a struct have a longer lifetime than the structure, therefore we can't completely get rid of all the accesses on top of sharef refs, only the rightmost one. Here is a possible example: ```rust struct MyStruct<'a> { a: &'static A, b: B, c: C<'a>, } fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static { let c = || drop(&*m.a.field_of_a); // Here we really do want to capture `*m.a` because that outlives `'static` // If we capture `m`, then the closure no longer outlives `'static' // it is constrained to `'a` } ``` r? `@nikomatsakis`
2021-07-08Consider capture kind for auto traits migrationRoxane-1/+1
2021-07-08Add new test caseRoxane-0/+13
2021-07-06Rename lintRyan Levick-0/+19
2021-07-06Rename disjoint_capture_migration lint to ↵Ryan Levick-168/+170
rust_2021_incompatible_closure_captures
2021-07-04be conservative in has_significant_dropNiko Matsakis-0/+34
2021-06-29Edition 2021 for testsAman Arora-35/+8
2021-06-292229: Reduce the size of closures with `capture_disjoint_fields`Aman Arora-10/+134
One key observation while going over the closure size profile of rustc was that we are disjointly capturing one or more fields starting at an immutable reference. Disjoint capture over immutable reference doesn't add too much value because the fields can either be borrowed immutably or copied. One possible edge case of the optimization is when a fields of a struct have a longer lifetime than the structure, therefore we can't completely get rid of all the accesses on top of sharef refs, only the rightmost one. Here is a possible example: ```rust struct MyStruct<'a> { a: &'static A, b: B, c: C<'a>, } fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static { let c = || drop(&*m.a.field_of_a); // Here we really do want to capture `*m.a` because that outlives `'static` // If we capture `m`, then the closure no longer outlives `'static' // it is constrained to `'a` } ```
2021-06-29Rollup merge of #86673 - m-ou-se:disjoint-capture-edition-lint, r=nikomatsakisYuki Okushi-104/+186
Make disjoint_capture_migration an edition lint. This turns the disjoint capture lint into an edition lint, and changes all the wording to refer to the edition. This includes the same first commit as https://github.com/rust-lang/rust/pull/86671. See https://github.com/rust-lang/rust/pull/86671. Fixes most of https://github.com/rust-lang/project-rfc-2229/issues/43#issuecomment-869188197
2021-06-27Editon 2021 enables precise captureAman Arora-1279/+451
2021-06-27Make disjoint_capture_migration an edition lint.Mara Bos-104/+186
2021-06-24fixup! 2229: Capture box completely in move closuresAman Arora-4/+4
fixup! 2229: Capture box completely in move closures
2021-06-242229: Capture box completely in move closuresAman Arora-8/+130
Even if the content from box is used in a sharef-ref context, we capture the box entirerly. This is motivated by: 1) We only capture data that is on the stack. 2) Capturing data from within the box might end up moving more data than the user anticipated.
2021-06-22Edition 2021 enables disjoint captureAman Arora-0/+23