Add test for implicitly capturing late-bound var with new capture rules · rust-lang/rust@acba7ef (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
1 | +// known-bug: #117647 | |
2 | + | |
3 | +#![feature(lifetime_capture_rules_2024)] | |
4 | +#![feature(rustc_attrs)] | |
5 | +#![allow(internal_features)] | |
6 | +#![rustc_variance_of_opaques] | |
7 | + | |
8 | +use std::ops::Deref; | |
9 | + | |
10 | +fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { | |
11 | +Box::new(x) | |
12 | +} | |
13 | + | |
14 | +fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
1 | +error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level | |
2 | + --> $DIR/implicit-capture-late.rs:10:36 | |
3 | + | | |
4 | +LL | fn foo(x: Vec) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { | |
5 | + | ^^ | |
6 | + | |
7 | +error: aborting due to 1 previous error | |
8 | + | |
9 | +For more information about this error, try `rustc --explain E0657`. |