about summary refs log tree commit diff
path: root/src/test/ui/async-await/in-trait
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-872/+0
2023-01-08Mention signature rather than fn pointers when comparing impl/trait methodsMichael Goulet-2/+2
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-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-05Make get_impl_future_output_ty work with AFITMichael Goulet-0/+37
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-02Check lifetime param count in collect_trait_impl_trait_tysMichael Goulet-0/+41
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-59/+2
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-12Add test for projections in async-in-trait.Camille GILLOT-59/+2
2022-11-01Don't remap early-bound RPITIT regions that originate from implMichael Goulet-0/+32
2022-10-27Update tests based on feedbackBryan Garza-26/+7
- Add comment to some tests that will break when #102745 is implemented - Mark a test with known-bug - Delete duplicate test
2022-10-27Update src/test/ui/async-await/in-trait/async-example.rsBryan Garza-2/+2
Co-authored-by: Michael Goulet <michael@errs.io>
2022-10-27Add additional tests for static AFITBryan Garza-0/+169
2022-10-27Update tests based on feedbackBryan Garza-33/+48
2022-10-27Update static AFIT tests based on feedbackBryan Garza-144/+28
2022-10-27Add tests for static async functions in traitsBryan Garza-0/+530
This patch adds test cases for AFIT, the majority of which are currently expected to run as `check-fail`.
2022-10-15Add testMichael Goulet-0/+15
2022-09-25Only generate closure def id for async fns with bodyMichael Goulet-0/+10
2022-09-24Resolve async fn signature even without body (in trait)Michael Goulet-0/+46