rust/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.rs

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

19 lines
394 B
Rust
Raw Normal View History

2023-05-29 10:20:42 -05:00
// 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);
}