Skip to content

Commit

Permalink
Add test for implicitly capturing late-bound var with new capture rules
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Dec 5, 2023
1 parent 0ad160a commit acba7ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/ui/impl-trait/implicit-capture-late.rs
Original file line number Diff line number Diff line change
@@ -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() {}
9 changes: 9 additions & 0 deletions tests/ui/impl-trait/implicit-capture-late.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit acba7ef

Please sign in to comment.