diff options
| author | Michael Goulet <michael@errs.io> | 2023-10-19 19:01:59 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-12-05 19:53:59 +0000 |
| commit | acba7efe1ba688cac04810406ca27dbab60520fd (patch) | |
| tree | 150022582d3ad3af581084df77a5355fab018ad1 | |
| parent | 0ad160a585672512303523c33e144092709459e6 (diff) | |
| download | rust-acba7efe1ba688cac04810406ca27dbab60520fd.tar.gz rust-acba7efe1ba688cac04810406ca27dbab60520fd.zip | |
Add test for implicitly capturing late-bound var with new capture rules
| -rw-r--r-- | tests/ui/impl-trait/implicit-capture-late.rs | 14 | ||||
| -rw-r--r-- | tests/ui/impl-trait/implicit-capture-late.stderr | 9 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/implicit-capture-late.rs b/tests/ui/impl-trait/implicit-capture-late.rs new file mode 100644 index 00000000000..8bfb16760c9 --- /dev/null +++ b/tests/ui/impl-trait/implicit-capture-late.rs @@ -0,0 +1,14 @@ +// known-bug: #117647 + +#![feature(lifetime_capture_rules_2024)] +#![feature(rustc_attrs)] +#![allow(internal_features)] +#![rustc_variance_of_opaques] + +use std::ops::Deref; + +fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { + Box::new(x) +} + +fn main() {} diff --git a/tests/ui/impl-trait/implicit-capture-late.stderr b/tests/ui/impl-trait/implicit-capture-late.stderr new file mode 100644 index 00000000000..9b3a4ff5f42 --- /dev/null +++ b/tests/ui/impl-trait/implicit-capture-late.stderr @@ -0,0 +1,9 @@ +error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level + --> $DIR/implicit-capture-late.rs:10:36 + | +LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { + | ^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0657`. |
