rust/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.rs
2023-05-29 18:37:53 +02:00

19 lines
394 B
Rust

// edition:2021
// regression test for #112056
fn extend_lifetime<'a, 'b>(x: &mut (&'a str,), y: &'b str) {
let mut closure = |input| x.0 = input;
//~^ ERROR: lifetime may not live long enough
closure(y);
}
fn main() {
let mut tuple = ("static",);
{
let x = String::from("temporary");
extend_lifetime(&mut tuple, &x);
}
println!("{}", tuple.0);
}