about summary refs log tree commit diff
path: root/src/test/ui/async-await
AgeCommit message (Collapse)AuthorLines
2022-02-12Inherit lifetimes for async fn instead of duplicating them.Camille GILLOT-41/+50
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-92/+48
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-09Rollup merge of #93751 - eholk:issue-93648-drop-tracking-projection, r=tmiaskoYuki Okushi-0/+12
Drop tracking: track borrows of projections Previous efforts to ignore partially consumed values meant we were also not considering borrows of a projection. This led to cases where we'd miss borrowed types which MIR expected to be there, leading to ICEs. This PR also includes the `-Zdrop-tracking` flag from #93313. If that PR lands first, I'll rebase to drop the commit from this one. Fixes #93648
2022-02-07Drop tracking: improve break and continue handlingEric Holk-0/+1
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-02-07Drop tracking: track borrows of projectionsEric Holk-0/+12
Previous efforts to ignore partially consumed values meant we were also not considering borrows of a projection. This led to cases where we'd miss borrowed types which MIR expected to be there, leading to ICEs.
2022-02-02Guess head span of async blocksOli Scherer-16/+5
2022-02-02undo a useless changeOli Scherer-3/+4
2022-02-02Register member constraints on the final merged hidden typeOli Scherer-14/+24
Previously we did this per hidden type candiate, which didn't always have all the information available.
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-54/+98
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-01Auto merge of #93284 - eholk:disable-drop-range-analysis, r=pnkfelixbors-0/+15
Disable drop range analysis The previous PR, #93165, still performed the drop range analysis despite ignoring the results. Unfortunately, there were ICEs in the analysis as well, so some packages failed to build (see the issue #93197 for an example). This change further disables the analysis and just provides dummy results in that case.
2022-01-27Improve suggestion for escaping reserved keywordsNoah Lev-24/+24
2022-01-26Change test to check-passEric Holk-1/+1
2022-01-25Add regression test for #93197Eric Holk-0/+15
2022-01-23Auto merge of #93220 - matthiaskrgr:rollup-9bkrlk0, r=matthiaskrgrbors-0/+38
Rollup of 8 pull requests Successful merges: - #90666 (Stabilize arc_new_cyclic) - #91122 (impl Not for !) - #93068 (Fix spacing for `·` between stability and source) - #93103 (Tweak `expr.await` desugaring `Span`) - #93113 (Unify search input and buttons size) - #93168 (update uclibc instructions for new toolchain, add link from platforms doc) - #93185 (rustdoc: Make some `pub` items crate-private) - #93196 (Remove dead code from build_helper) Failed merges: - #93188 (rustdoc: fix bump down typing search on Safari) r? `@ghost` `@rustbot` modify labels: rollup
2022-01-23Rollup merge of #93103 - estebank:await-span, r=nagisaMatthias Krüger-0/+38
Tweak `expr.await` desugaring `Span` Fix #93074
2022-01-21Disable drop range tracking in generatorsEric Holk-0/+8
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-21Auto merge of #93138 - matthiaskrgr:rollup-m8akifd, r=matthiaskrgrbors-73/+93
Rollup of 17 pull requests Successful merges: - #91032 (Introduce drop range tracking to generator interior analysis) - #92856 (Exclude "test" from doc_auto_cfg) - #92860 (Fix errors on blanket impls by ignoring the children of generated impls) - #93038 (Fix star handling in block doc comments) - #93061 (Only suggest adding `!` to expressions that can be macro invocation) - #93067 (rustdoc mobile: fix scroll offset when jumping to internal id) - #93086 (Add tests to ensure that `let_chains` works with `if_let_guard`) - #93087 (Fix src/test/run-make/raw-dylib-alt-calling-convention) - #93091 (⬆ chalk to 0.76.0) - #93094 (src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs`) - #93098 (Show a more informative panic message when `DefPathHash` does not exist) - #93099 (rustdoc: auto create output directory when "--output-format json") - #93102 (Pretty printer algorithm revamp step 3) - #93104 (Support --bless for pp-exact pretty printer tests) - #93114 (update comment for `ensure_monomorphic_enough`) - #93128 (Add script to prevent point releases with same number as existing ones) - #93136 (Backport the 1.58.1 release notes to master) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-20Tweak `expr.await` desugaring `Span`Esteban Kuber-0/+38
Fix #93074
2022-01-19Simplify error reporting code, remove await point wordingTyler Mandry-7/+4
2022-01-19NiceRegionError: Use written return type for async fnTyler Mandry-11/+5
2022-01-18Safely handle partial dropsEric Holk-0/+56
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-18Update async-fn-nonsend.rsEric Holk-5/+43
The previous commit made the non_sync_with_method_call case pass due to the await being unreachable. Unfortunately, this isn't actually the behavior the test was verifying. This change lifts the panic into a helper function so that the generator analysis still thinks the await is reachable, and therefore we preserve the same testing behavior.
2022-01-18Handle uninhabited return typesEric Holk-29/+3
This changes drop range analysis to handle uninhabited return types such as `!`. Since these calls to these functions do not return, we model them as ending in an infinite loop.
2022-01-18Handle empty loops betterEric Holk-4/+12
2022-01-18Update stderr filesEric Holk-4/+4
2022-01-18Update async-fn-nonsend.stderrEric Holk-29/+6
2022-01-18Attribute drop to parent expression of the consume pointEric Holk-1/+33
This is needed to handle cases like `[a, b.await, c]`. `ExprUseVisitor` considers `a` to be consumed when it is passed to the array, but the array is not quite live yet at that point. This means we were missing the `a` value across the await point. Attributing drops to the parent expression means we do not consider the value consumed until the consuming expression has finished. Issue #57478
2022-01-18Make generator and async-await tests passEric Holk-3/+2
The main change needed to make this work is to do a pessimistic over- approximation for AssignOps. The existing ScopeTree analysis in region.rs works by doing both left to right and right to left order and then choosing the most conservative ordering. This behavior is needed because AssignOp's evaluation order depends on whether it is a primitive type or an overloaded operator, which runs as a method call. This change mimics the same behavior as region.rs in generator_interior.rs. Issue #57478
2022-01-18Track drop points in generator_interiorEric Holk-69/+5
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
2022-01-06Normalize generator-local types with unevaluated constantsMichael Goulet-0/+26
2021-12-17Fix typo in "new region bound" suggestionEsteban Kuber-2/+2
The lifetime name shoud always appear in text surrounded by `.
2021-12-13review comment: change wording of suggestionEsteban Kuber-3/+3
2021-12-13review commentsEsteban Kuber-9/+17
2021-12-13tidy fixEsteban Kuber-1/+1
2021-12-13Fix rebase and clippy testsEsteban Kuber-62/+44
2021-12-13Keep info on pre-desugaring expression for better "incorrect `.await`" ↵Esteban Kuber-0/+36
suggestion Keep the `HirId` of `.await`ed expressions so in the case of a `fn` call on on a sync `fn`, we can suggest maybe turning it into an `async fn`.
2021-12-13When `.await` is called on a non-`Future` expression, suggest removalEsteban Kuber-105/+119
Keep track of the origin of a `T: Future` obligation when caused by an `.await` expression. Address #66731.
2021-12-11Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgrbors-5/+71
Rollup of 6 pull requests Successful merges: - #83174 (Suggest using a temporary variable to fix borrowck errors) - #89734 (Point at capture points for non-`'static` reference crossing a `yield` point) - #90270 (Make `Borrow` and `BorrowMut` impls `const`) - #90741 (Const `Option::cloned`) - #91548 (Add spin_loop hint for RISC-V architecture) - #91721 (Minor improvements to `future::join!`'s implementation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-11Rollup merge of #89734 - estebank:issue-72312, r=nikomatsakisMatthias Krüger-5/+71
Point at capture points for non-`'static` reference crossing a `yield` point ``` error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-72312.rs:10:24 | LL | pub async fn start(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... ... LL | require_static(async move { | -------------- ...is required to live as long as `'static` here... LL | &self; | ----- ...and is captured here | note: `'static` lifetime requirement introduced by this trait bound --> $DIR/issue-72312.rs:2:22 | LL | fn require_static<T: 'static>(val: T) -> T { | ^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0759`. ``` Fix #72312.
2021-12-11Rollup merge of #91640 - cjgillot:in-band-collect, r=oli-obkMatthias Krüger-0/+11
Simplify collection of in-band lifetimes Split from https://github.com/rust-lang/rust/pull/91403 r? ````@oli-obk````
2021-12-10Tweak wordingEsteban Kuber-3/+3
2021-12-10rebase and update nll testEsteban Kuber-2/+8
2021-12-10Update nll testEsteban Kuber-0/+15
2021-12-10Add filtering based on involved required lifetimeEsteban Kuber-6/+1
More accurate filtering still needed.
2021-12-10Clean up visual output logicEsteban Kuber-11/+14
2021-12-10Point at capture points for non-`'static` reference crossing a `yield` pointEsteban Kuber-5/+52
``` error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-72312.rs:10:24 | LL | pub async fn start(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... ... LL | require_static(async move { | -------------- ...is required to live as long as `'static` here... LL | &self; | ----- ...and is captured here | note: `'static` lifetime requirement introduced by this trait bound --> $DIR/issue-72312.rs:2:22 | LL | fn require_static<T: 'static>(val: T) -> T { | ^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0759`. ``` Fix #72312.
2021-12-09Add needs-unwind to tests that depend on panickingDavid Koloski-0/+1
This directive isn't automatically set by compiletest or x.py, but can be turned on manually for targets that require it.
2021-12-07Use collect_in_band_defs for async lifetime captures.Camille GILLOT-0/+11
2021-12-05Pretty print async block without redundant spaceDavid Tolnay-5/+5
2021-12-05Rollup merge of #91437 - dtolnay:emptybrace, r=nagisaMatthias Krüger-3/+3
Pretty print empty blocks as {} **Example:** ```rust macro_rules! p { ($e:expr) => { println!("{}", stringify!($e)); }; ($i:item) => { println!("{}", stringify!($i)); }; } fn main() { p!(if true {}); p!(struct S {}); } ``` **Before:** ```console if true { } struct S { } ``` **After:** ```console if true {} struct S {} ``` This affects [`dbg!`](https://doc.rust-lang.org/std/macro.dbg.html), as well as ecosystem uses of stringify such as in [`anyhow::ensure!`](https://docs.rs/anyhow/1/anyhow/macro.ensure.html). Printing a `{ }` in today's heavily rustfmt'd world comes out looking jarring/sloppy.