summary refs log tree commit diff
path: root/src/test/ui/generator
AgeCommit message (Collapse)AuthorLines
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-1/+1
2022-07-28--bless testsMaybe Waffle-4/+9
2022-07-21Add regression test for #52304Yuki Okushi-0/+11
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-19Mention first and last macro in backtraceMichael Goulet-1/+1
2022-07-10Fix drop-tracking ICE when a struct containing a field with a `Drop` impl is ↵Joshua Nelson-11/+258
used across an await Previously, drop-tracking would incorrectly assume the struct would be dropped immediately, which was not true: when the field had a type with a manual `Drop` impl, the drop becomes observable and has to be dropped after the await instead. For reasons I don't understand, this also fixes another error crater popped up related to type parameters. #98476
2022-07-08Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebankbors-46/+22
Shorten def_span of closures to just their header Continuation of https://github.com/rust-lang/rust/pull/93967.
2022-07-07Tweak wording and spansEsteban Küber-9/+9
2022-07-07On partial uninit error point at where we need initEsteban Küber-14/+23
When a binding is declared without a value, borrowck verifies that all codepaths have *one* assignment to them to initialize them fully. If there are any cases where a condition can be met that leaves the binding uninitialized or we attempt to initialize a field of an unitialized binding, we emit E0381. We now look at all the statements that initialize the binding, and use them to explore branching code paths that *don't* and point at them. If we find *no* potential places where an assignment to the binding might be missing, we display the spans of all the existing initializers to provide some context.
2022-07-07Shorten span for closures.Camille GILLOT-46/+22
2022-06-19Greatly improve error reporting for futures and generators in ↵Joshua Nelson-19/+99
`note_obligation_cause_code` Most futures don't go through this code path, because they're caught by `maybe_note_obligation_cause_for_async_await`. But all generators do, and `maybe_note` is imperfect and doesn't catch all futures. Improve the error message for those it misses. At some point, we may want to consider unifying this with the code for `maybe_note_async_await`, so that `async_await` notes all parent constraints, and `note_obligation` can point to yield points. But both functions are quite complicated, and it's not clear to me how to combine them; this seems like a good incremental improvement.
2022-06-11ValuePairs::PolyTraitRefs should be called 'trait'Michael Goulet-2/+2
2022-06-07Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakisbors-128/+10
Remove migrate borrowck mode Closes #58781 Closes #43234 # Stabilization proposal This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile. Tracking issue: #43234 RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable). ## Motivation Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors. The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition. In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker. In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver. While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff. ## What is stabilized As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise. There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl. As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions. ## What isn't stabilized This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck. ## Tests Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll` ## History * On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234) * On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271) * On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094) * On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825) * On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862) * On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083) * On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681) * On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114) * On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221) * On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-04Add regresion test for #87142Yuki Okushi-0/+32
2022-06-03Fully stabilize NLLJack Huey-128/+10
2022-05-22Use revisions for NLL in generatorJack Huey-24/+39
2022-05-21Auto merge of #96923 - eholk:fix-fake-read, r=nikomatsakisbors-0/+41
Drop Tracking: Implement `fake_read` callback This PR updates drop tracking's use of `ExprUseVisitor` so that we treat `fake_read` events as borrows. Without doing this, we were not handling match expressions correctly, which showed up as a breakage in the `addassign-yield.rs` test. We did not previously notice this because we still had rather large temporary scopes that we held borrows for, which changed in #94309. This PR also includes a variant of the `addassign-yield.rs` test case to make sure we continue to have correct behavior here with drop tracking. r? `@nikomatsakis`
2022-05-19Borrow guard patterns for the body of the guardEric Holk-9/+0
2022-05-19Revert "Count copies of locals as borrowed temporaries"Eric Holk-13/+1
This reverts commit 0d270b5e9f48268735f9a05462df65c9d1039855.
2022-05-19Count copies of locals as borrowed temporariesEric Holk-1/+13
2022-05-19Further reduce test caseEric Holk-9/+5
Thanks to @tmiasko for this one!
2022-05-19Add drop tracking version of yielding-in-match-guard.rsEric Holk-0/+25
2022-05-10Revert spurious changeEric Holk-21/+21
2022-05-10Fix addassign-yield.rs by implementing fake_readEric Holk-21/+21
2022-05-10Add test case for the need for fake_read callbacksEric Holk-0/+41
2022-05-06Resolve vars in note_type_errJack Huey-1/+1
2022-04-28Revert diagnostic duplication and accidental stabilizationOli Scherer-41/+5
2022-04-20Rollup merge of #93313 - tmiasko:uninhabited, r=tmandryDylan DPC-1/+2
Check if call return type is visibly uninhabited when building MIR The main motivation behind the change is to expose information about diverging calls to the generator transform and match the precision of drop range tracking which already understands that call expressions with visibly uninhabited types diverges. This change should also accept strictly more programs than before. That is programs that were previously rejected due to errors raised by control-flow sensitive checks in a code that is no longer considered reachable. Fixes #93161.
2022-03-28Revert to inference variable based hidden type computation for RPITOli Scherer-20/+52
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-14/+20
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-24Check if call return type is visibly uninhabited when building MIRTomasz Miąsko-1/+2
2022-03-07Move test to right placeEric Holk-0/+22
2022-03-05Rollup merge of #94460 - eholk:reenable-drop-tracking-tests, r=tmiaskoDylan DPC-23/+14
Reenable generator drop tracking tests and fix mutation handling The previous PR, #94068, was overly zealous in counting mutations as borrows, which effectively nullified drop tracking. We would have caught this except the drop tracking tests were still ignored, despite having the option of using the `-Zdrop-tracking` flag now. This PR fixes the issue introduced by #94068 by only counting mutations as borrows the mutated place has a project. This is sufficient to distinguish `x.y = 42` (which should count as a borrow of `x`) from `x = 42` (which is not a borrow of `x` because the whole variable is overwritten). This PR also re-enables the drop tracking regression tests using the `-Zdrop-tracking` flag so we will avoid introducing these sorts of issues in the future. Thanks to ``@tmiasko`` for noticing this problem and pointing it out! r? ``@tmiasko``
2022-03-03Cleanup feature gates.Camille GILLOT-1/+1
2022-02-28Enable drop-tracking tests behind -Zdrop-trackingEric Holk-23/+14
These were still disabled from the soft revert of drop tracking, which meant we were not catching regressions that were introduced while trying to fix drop tracking.
2022-02-07Drop tracking: improve break and continue handlingEric Holk-0/+18
This commit fixes two issues. One, sometimes break or continue have a block target instead of an expression target. This seems to mainly happen with try blocks. Since the drop tracking analysis only works on expressions, if we see a block target for break or continue, we substitute the last expression of the block as the target instead. Two, break and continue were incorrectly being treated as the same, so continue would also show up as an exit from the loop or block. This patch corrects the way continue is handled by keeping a stack of loop entry points and uses those to find the target of the continue.
2022-01-23Auto merge of #93165 - eholk:disable-generator-drop-tracking, r=nikomatsakisbors-0/+105
Disable drop range tracking in generators Generator drop tracking caused an ICE for generators involving the Never type (Issue #93161). Since this breaks a test case with miri, we temporarily disable drop tracking so miri is unblocked while we properly fix the issue.
2022-01-21Auto merge of #92363 - the8472:less-compiletest-normalization, r=Mark-Simulacrumbors-5/+5
Override rustc version in ui and mir-opt tests to get stable hashes Building a dozen separate regexps for each test in compiletest consumes significant amounts of CPU cycles. UI test timings on my machine: OLD: 39.63s NEW: 30.27s
2022-01-21Add regression test for #93161Eric Holk-0/+93
2022-01-21Disable drop range tracking in generatorsEric Holk-0/+12
Generator drop tracking caused an ICE for generators involving the Never type (Issue #93161). Since this breaks miri, we temporarily disable drop tracking so miri is unblocked while we properly fix the issue.
2022-01-21Override rustc version in ui and mir-opt tests to get stable hashesThe 8472-5/+5
Building a dozen separate regexps for each test in compiletest consumes significant amounts of CPU cycles. Using `RUSTC_FORCE_INCR_COMP_ARTIFACT_HEADER` stabilizes hashes calcuated for the individual tests so no test-dependent normalization is needed. Hashes for the standard library still change so some normalizations are still needed.
2022-01-18Respond to code review commentsEric Holk-4/+69
2022-01-18Safely handle partial dropsEric Holk-2/+27
We previously weren't tracking partial re-inits while being too aggressive around partial drops. With this change, we simply ignore partial drops, which is the safer, more conservative choice.
2022-01-18Handle reinits in match guardsEric Holk-0/+25
2022-01-18Address code review commentsEric Holk-0/+21
1. Add test case for partial drops 2. Simplify code in `propagate_to_fixpoint` and remove most clones 3. Clean up PostOrderIndex creation
2022-01-18Handle more cases with conditionally initialized/dropped valuesEric Holk-2/+42
2022-01-18Basic loop supportEric Holk-1/+1
2022-01-18Support reinitialization of variablesEric Holk-22/+81
2022-01-18Support conditional dropsEric Holk-0/+22
This adds support for branching and merging control flow and uses this to correctly handle the case where a value is dropped in one branch of an if expression but not another. There are other cases we need to handle, which will come in follow up patches. Issue #57478
2022-01-18Track drops across multiple yieldsEric Holk-0/+40
2022-01-18Track drop points in generator_interiorEric Holk-0/+2
This change adds the basic infrastructure for tracking drop ranges in generator interior analysis, which allows us to exclude dropped types from the generator type. Not yet complete, but many of the async/await and generator tests pass. The main missing piece is tracking branching control flow (e.g. around an `if` expression). The patch does include support, however, for multiple yields in th e same block. Issue #57478