blob: cb715c0cdb9e54ac89142ad07c9b89bf647de529 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
fn match_ref(&&v: Option<int>) -> int {
match v {
Some(ref i) => {
*i
}
None => {0}
}
}
fn match_ref_unused(&&v: Option<int>) {
match v {
Some(_) => {}
None => {}
}
}
fn match_const_reg(v: &const Option<int>) -> int {
match *v {
Some(ref i) => {*i} // OK because this is pure
None => {0}
}
}
fn impure(_i: int) {
}
fn match_const_reg_unused(v: &const Option<int>) {
match *v {
Some(_) => {impure(0)} // OK because nothing is captured
None => {}
}
}
fn match_const_reg_impure(v: &const Option<int>) {
match *v {
Some(ref i) => {impure(*i)} //~ ERROR illegal borrow unless pure
//~^ NOTE impure due to access to impure function
None => {}
}
}
fn match_imm_reg(v: &Option<int>) {
match *v {
Some(ref i) => {impure(*i)} // OK because immutable
None => {}
}
}
fn main() {
}
|