]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-36082.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / issue-36082.rs
1 // run-rustfix
2 use std::cell::RefCell;
3
4 fn main() {
5     let mut r = 0;
6     let s = 0;
7     let x = RefCell::new((&mut r,s));
8
9     let val: &_ = x.borrow().0;
10     //~^ ERROR temporary value dropped while borrowed [E0716]
11     //~| NOTE temporary value is freed at the end of this statement
12     //~| NOTE creates a temporary value which is freed while still in use
13     //~| HELP consider using a `let` binding to create a longer lived value
14     println!("{}", val);
15     //~^ borrow later used here
16 }