rust/tests/ui/borrowck/alias-liveness/opaque-capture.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
484 B
Rust
Raw Normal View History

2023-10-14 09:28:44 -05:00
//@ check-pass
// Check that opaques capturing early and late-bound vars correctly mark
// regions required to be live using the item bounds.
trait Captures<'a> {}
impl<T> Captures<'_> for T {}
fn captures_temp_late<'a>(x: &'a Vec<i32>) -> impl Sized + Captures<'a> + 'static {}
fn captures_temp_early<'a: 'a>(x: &'a Vec<i32>) -> impl Sized + Captures<'a> + 'static {}
fn test() {
let x = captures_temp_early(&vec![]);
let y = captures_temp_late(&vec![]);
}
fn main() {}