From acba7efe1ba688cac04810406ca27dbab60520fd Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 19 Oct 2023 19:01:59 +0000 Subject: [PATCH] Add test for implicitly capturing late-bound var with new capture rules --- tests/ui/impl-trait/implicit-capture-late.rs | 14 ++++++++++++++ tests/ui/impl-trait/implicit-capture-late.stderr | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/ui/impl-trait/implicit-capture-late.rs create mode 100644 tests/ui/impl-trait/implicit-capture-late.stderr 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 0000000000000..8bfb16760c918 --- /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) -> Box Deref> { + 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 0000000000000..9b3a4ff5f4250 --- /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) -> Box Deref> { + | ^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0657`.