diff options
| author | Michael Goulet <michael@errs.io> | 2024-08-06 15:43:28 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-08-06 15:43:41 -0400 |
| commit | c656ce7aebe23b8d895f485b131da5d296a78c8c (patch) | |
| tree | 24f1adc17a3c1ff8d26189069e8734b2d91b173a /tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs | |
| parent | 60d146580c10036ce89e019422c6bc2fd9729b65 (diff) | |
| download | rust-c656ce7aebe23b8d895f485b131da5d296a78c8c.tar.gz rust-c656ce7aebe23b8d895f485b131da5d296a78c8c.zip | |
Don't arbitrarily choose one upper bound for hidden captured region
Diffstat (limited to 'tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs')
| -rw-r--r-- | tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs b/tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs new file mode 100644 index 00000000000..d7b62436d2d --- /dev/null +++ b/tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs @@ -0,0 +1,29 @@ +#![feature(precise_capturing)] + +use std::future::Future; +use std::pin::Pin; + +trait MyTrait { + fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = i32>; +} + +trait ErasedMyTrait { + fn foo<'life0, 'life1, 'dynosaur>(&'life0 self, x: &'life1 i32) + -> Pin<Box<dyn Future<Output = i32> + 'dynosaur>> + where + 'life0: 'dynosaur, + 'life1: 'dynosaur; +} + +struct DynMyTrait<T: ErasedMyTrait> { + ptr: T, +} + +impl<T: ErasedMyTrait> MyTrait for DynMyTrait<T> { + fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = i32> { + self.ptr.foo(x) + //~^ ERROR hidden type for `impl Future<Output = i32>` captures lifetime that does not appear in bounds + } +} + +fn main() {} |
