about summary refs log tree commit diff
path: root/src/test/ui/async-await
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-12053/+0
2023-01-09Consider method return type for various method suggestionsMichael Goulet-0/+33
2023-01-08Mention signature rather than fn pointers when comparing impl/trait methodsMichael Goulet-2/+2
2023-01-01Verbose suggestionsEsteban Küber-4/+10
2022-12-30Add regression test for #105501Arpad Borsos-0/+165
The test was minified from the published `msf-ice:0.2.1` crate which failed in a crater run. A faulty compiler was triggering a `higher-ranked lifetime error`: > could not prove `[async block@...]: Send`
2022-12-22Rollup merge of #104741 - bryangarza:bug-104588-async-track-caller, ↵Matthias Krüger-22/+52
r=compiler-errors Switch `#[track_caller]` back to a no-op unless feature gate is enabled This patch fixes a regression, in which `#[track_caller]`, which was previously a no-op, was changed to actually turn on the behavior. This should instead only happen behind the `closure_track_caller` feature gate. Also, add a warning for the user to understand how their code will compile depending on the feature gate being turned on or not. Fixes #104588
2022-12-21Update track_caller tests; run fmtBryan Garza-15/+7
2022-12-21Test that async blocks are UnwindSafeArpad Borsos-0/+68
This was a regression from the reverted #105250 which is now covered by a test.
2022-12-21Improve code based on feedback.Bryan Garza-23/+7
This patch improves the readability of some of the code by using if-let-chains. Also, make use of the `add_feature_diagnostics` function.
2022-12-21Update track_caller logic/lint after rebaseBryan Garza-7/+12
2022-12-21update wording of lintBryan Garza-2/+2
2022-12-21Update code based on PR commentsBryan Garza-102/+40
This patch does the following: - Refactor some repeated lines into a single one - Split the `ungated_async_fn_caller` lint into multiple lines, and make one of those lines only print out on nightly - Use test revisions instead of copying an existing test
2022-12-21Switch `#[track_caller]` back to a no-op unless feature gate is enabledBryan Garza-0/+111
This patch fixes a regression, in which `#[track_caller]`, which was previously a no-op, was changed to actually turn on the behavior. This should instead only happen behind the `closure_track_caller` feature gate. Also, add a warning for the user to understand how their code will compile depending on the feature gate being turned on or not. Fixes #104588
2022-12-20Add regression test for #102206Yuki Okushi-0/+31
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-12-19Revert "Replace usage of `ResumeTy` in async lowering with `Context`"Andrew Pollack-9/+6
2022-12-17Rollup merge of #105711 - compiler-errors:rpitit-references-errors, r=eholkMatthias Krüger-0/+42
bail in `collect_trait_impl_trait_tys` if signatures reference errors Fixes #105290
2022-12-15Rollup merge of #105692 - JohnTitor:issue-104678, r=compiler-errorsMatthias Krüger-0/+31
Add regression test for #104678 Closes #104678 r? `````@compiler-errors````` Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-12-14Ensure async trait impls are async (or otherwise return an opaque type)Dan Johnson-25/+99
As a workaround for the full `#[refine]` semantics not being implemented yet, forbit returning a concrete future type like `Box<dyn Future>` or a manually implemented Future. `-> impl Future` is still permitted; while that can also cause accidental refinement, that's behind a different feature gate (`return_position_impl_trait_in_trait`) and that problem exists regardless of whether the trait method is async, so will have to be solved more generally. Fixes #102745
2022-12-14bail in collect_trait_impl_trait_tys if signatures reference errorsMichael Goulet-0/+42
2022-12-14Add regression test for #104678Yuki Okushi-0/+31
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-12-13Rollup merge of #105500 - oli-obk:unhide_unknown_spans, r=estebankMatthias Krüger-53/+17
Make some diagnostics not depend on the source of what they reference being available r? `@estebank` follow up to https://github.com/rust-lang/rust/pull/104449
2022-12-13Rollup merge of #105464 - nbdd0121:hir, r=compiler-errorsMatthias Krüger-1/+65
Support #[track_caller] on async closures Follow up on #105180 r? ```@compiler-errors``` cc ```@cjgillot```
2022-12-13Use a label instead of a note for the drop site to create denser diagnosticsOli Scherer-35/+15
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-18/+2
available
2022-12-08Support `#[track_caller]` on async closuresGary Guo-1/+65
2022-12-08Rollup merge of #105255 - cjgillot:issue-105197, r=compiler-errorsMatthias Krüger-0/+17
Make nested RPIT inherit the parent opaque's generics. Fixes https://github.com/rust-lang/rust/issues/105197 r? ```@compiler-errors```
2022-12-07Rollup merge of #105267 - compiler-errors:issue-104613, r=oli-obkMatthias Krüger-0/+33
Don't ICE in ExprUseVisitor on FRU for non-existent struct Fixes #104613 Fixes #105202
2022-12-06Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obkMatthias Krüger-6/+9
Replace usage of `ResumeTy` in async lowering with `Context` Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air. fixes https://github.com/rust-lang/rust/issues/104828 and https://github.com/rust-lang/rust/pull/104321#issuecomment-1336363077 r? `@oli-obk`
2022-12-06Rollup merge of #105318 - compiler-errors:issue-105304, r=jackh726Matthias Krüger-0/+37
Make `get_impl_future_output_ty` work with AFIT Fixes #105304
2022-12-06Replace usage of `ResumeTy` in async lowering with `Context`Arpad Borsos-6/+9
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air.
2022-12-05Rollup merge of #105180 - nbdd0121:async_track_caller, r=compiler-errorsMatthias Krüger-0/+25
Use proper HirId for async track_caller attribute check Fix #105134
2022-12-05Make get_impl_future_output_ty work with AFITMichael Goulet-0/+37
2022-12-05Unconditional check FRU expression, even if there are errors presentMichael Goulet-0/+33
2022-12-04Auto merge of #105094 - Swatinem:generator-not-future, r=compiler-errorsbors-0/+126
Make sure async constructs do not `impl Generator` Async lowering turns async functions and blocks into generators internally. Though these special kinds of generators should not `impl Generator` themselves. The other way around, normal generators should not `impl Future`. This was discovered in https://github.com/rust-lang/rust/pull/105082#issuecomment-1332210907 and is a regression from https://github.com/rust-lang/rust/pull/104321. r? `@compiler-errors`
2022-12-04Make nested RPITIT inherit the parent opaque's generics.Camille GILLOT-0/+17
2022-12-04Use parent function WfCheckingContext to check RPITIT.Camille GILLOT-58/+23
2022-12-02Fix async track caller for assoc fn and trait impl fnGary Guo-0/+14
2022-12-02Use proper HirId for async track_caller attribute checkGary Guo-0/+11
2022-12-02Check lifetime param count in collect_trait_impl_trait_tysMichael Goulet-0/+41
2022-11-30Make sure async constructs do not `impl Generator`Arpad Borsos-0/+126
Async lowering turns async functions and blocks into generators internally. Though these special kinds of generators should not `impl Generator` themselves. The other way around, normal generators should not `impl Future`.
2022-11-27Rollup merge of #104931 - Swatinem:async-pretty, r=eholkMatthias Krüger-13/+13
Pretty-print generators with their `generator_kind` After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally. This now reverses that change so that async fn/blocks are pretty-printed as `[$async-type@$source-position]` in various diagnostics, and updates the tests that this touches.
2022-11-26Rewrite dest prop.Jakob Degen-8/+9
This fixes a number of correctness issues from the previous version. Additionally, we use a new strategy which has much better performance charactersitics and also finds more opportunities to apply the optimization.
2022-11-26Pretty-print generators with their `generator_kind`Arpad Borsos-13/+13
After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally. This now reverses that change so that async fn/blocks are pretty-printed as `[$movability `async` $something@$source-position]` in various diagnostics, and updates the tests that this touches.
2022-11-24Auto merge of #104321 - Swatinem:async-gen, r=oli-obkbors-45/+33
Avoid `GenFuture` shim when compiling async constructs Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through. --- Given this demo code: ```rust pub async fn a(arg: u32) -> Backtrace { let bt = b().await; let _arg = arg; bt } pub async fn b() -> Backtrace { Backtrace::force_capture() } ``` I would get the following with the latest stable compiler (on Windows): ``` 4: async_codegen::b::async_fn$0 at .\src\lib.rs:10 5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 6: async_codegen::a::async_fn$0 at .\src\lib.rs:4 7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 ``` whereas now I get a much cleaner stack trace: ``` 3: async_codegen::b::async_fn$0 at .\src\lib.rs:10 4: async_codegen::a::async_fn$0 at .\src\lib.rs:4 ```
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-45/+33
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-23Pass InferCtxt to DropRangeVisitor so we can resolve varsMichael Goulet-0/+168
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-65/+72
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-19Improve spans for RPITIT object-safety errorsMichael Goulet-0/+40
2022-11-17Rollup merge of #103852 - compiler-errors:rpitit-early-from-impl, r=lcnrMatthias Krüger-0/+32
Don't remap early-bound regions for return-position `impl Trait` in trait originating from `impl` long title :sweat: We don't want to remap early-bound regions that originate from the `impl`s themselves, since they have no corresponding region in the trait. Not sure if there's a better condition than checking if the EBR's def-id's parent is the impl -- maybe we should be checking if the region comes from the method or RPITIT... :shrug: r? types Fixes #103850
2022-11-17Auto merge of #104219 - bryangarza:async-track-caller-dup, r=eholkbors-0/+76
Support `#[track_caller]` on async fns Adds `#[track_caller]` to the generator that is created when we desugar the async fn. Fixes #78840 Open questions: - What is the performance impact of adding `#[track_caller]` to every `GenFuture`'s `poll(...)` function, even if it's unused (i.e., the parent span does not set `#[track_caller]`)? We might need to set it only conditionally, if the indirection causes overhead we don't want.