]> git.proxmox.com Git - rustc.git/blame - src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / rfc-2005-default-binding-mode / borrowck-issue-49631.rs
CommitLineData
0531ce1d
XL
1#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2pub struct Foo {
3}
4
5impl Foo {
6 fn get(&self) -> Option<&Result<String, String>> {
7 None
8 }
9
10 fn mutate(&mut self) { }
11}
12
13fn main() {
14 let mut foo = Foo { };
15
16 // foo.get() returns type Option<&Result<String, String>>, so
17 // using `string` keeps borrow of `foo` alive. Hence calling
18 // `foo.mutate()` should be an error.
19 while let Some(Ok(string)) = foo.get() {
20 foo.mutate();
21 //~^ ERROR cannot borrow `foo` as mutable
22 println!("foo={:?}", *string);
23 }
24}