summaryrefslogtreecommitdiffstats
path: root/tests/ui/coercion/coerce-reborrow-mut-ptr-arg.rs
blob: 76cd6793b3c231d6e71dba3bae6b611832c58cf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// run-pass
// pretty-expanded FIXME #23616

struct SpeechMaker {
    speeches: usize
}

fn talk(x: &mut SpeechMaker) {
    x.speeches += 1;
}

fn give_a_few_speeches(speaker: &mut SpeechMaker) {

    // Here speaker is reborrowed for each call, so we don't get errors
    // about speaker being moved.

    talk(speaker);
    talk(speaker);
    talk(speaker);
}

pub fn main() {
    let mut lincoln = SpeechMaker {speeches: 22};
    give_a_few_speeches(&mut lincoln);
}