diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-12-04 13:54:41 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-12-04 13:54:56 +0000 |
| commit | 44948d1fdc97a4fd24594be77df673a2c3b40544 (patch) | |
| tree | 3c9dbdd0cfa89662bb304af55549a4a4097cd97c /src/test | |
| parent | cab4fd678c5b148a330f2bf255bf28a67dfea0fc (diff) | |
| download | rust-44948d1fdc97a4fd24594be77df673a2c3b40544.tar.gz rust-44948d1fdc97a4fd24594be77df673a2c3b40544.zip | |
Recurse into nested impl-trait when computing variance.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/impl-trait/nested-return-type4.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/nested-return-type4.stderr | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/nested-return-type4.rs b/src/test/ui/impl-trait/nested-return-type4.rs new file mode 100644 index 00000000000..cec70bb1a0d --- /dev/null +++ b/src/test/ui/impl-trait/nested-return-type4.rs @@ -0,0 +1,8 @@ +// edition: 2021 + +fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized> { + async move { let _s = s; } + //~^ ERROR hidden type for `impl Future<Output = impl Sized>` captures lifetime that does not appear in bounds +} + +fn main() {} diff --git a/src/test/ui/impl-trait/nested-return-type4.stderr b/src/test/ui/impl-trait/nested-return-type4.stderr new file mode 100644 index 00000000000..e761a60e79c --- /dev/null +++ b/src/test/ui/impl-trait/nested-return-type4.stderr @@ -0,0 +1,20 @@ +error[E0700]: hidden type for `impl Future<Output = impl Sized>` captures lifetime that does not appear in bounds + --> $DIR/nested-return-type4.rs:4:5 + | +LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized> { + | -- hidden type `[async block@$DIR/nested-return-type4.rs:4:5: 4:31]` captures the lifetime `'s` as defined here +LL | async move { let _s = s; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl Future<Output = impl Sized>` captures `'s`, you can add an explicit `'s` lifetime bound + | +LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized> + 's { + | ++++ +help: to declare that `impl Sized` captures `'s`, you can add an explicit `'s` lifetime bound + | +LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized + 's> { + | ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. |
