2012-08-06 20:14:46 -05:00
|
|
|
fn process<T>(_t: T) {}
|
|
|
|
|
2012-08-20 14:23:37 -05:00
|
|
|
fn match_const_opt_by_mut_ref(v: &const Option<int>) {
|
2012-08-06 20:14:46 -05:00
|
|
|
match *v {
|
2012-08-20 14:23:37 -05:00
|
|
|
Some(ref mut i) => process(i), //~ ERROR illegal borrow
|
|
|
|
None => ()
|
2012-08-06 20:14:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-20 14:23:37 -05:00
|
|
|
fn match_const_opt_by_const_ref(v: &const Option<int>) {
|
2012-08-06 20:14:46 -05:00
|
|
|
match *v {
|
2012-08-20 14:23:37 -05:00
|
|
|
Some(ref const i) => process(i), //~ ERROR illegal borrow unless pure
|
2012-08-06 20:14:46 -05:00
|
|
|
//~^ NOTE impure due to
|
2012-08-20 14:23:37 -05:00
|
|
|
None => ()
|
2012-08-06 20:14:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-20 14:23:37 -05:00
|
|
|
fn match_const_opt_by_imm_ref(v: &const Option<int>) {
|
2012-08-06 20:14:46 -05:00
|
|
|
match *v {
|
2012-08-20 14:23:37 -05:00
|
|
|
Some(ref i) => process(i), //~ ERROR illegal borrow unless pure
|
2012-08-06 20:14:46 -05:00
|
|
|
//~^ NOTE impure due to
|
2012-08-20 14:23:37 -05:00
|
|
|
None => ()
|
2012-08-06 20:14:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-20 14:23:37 -05:00
|
|
|
fn match_const_opt_by_value(v: &const Option<int>) {
|
2012-08-06 20:14:46 -05:00
|
|
|
match *v {
|
2012-08-20 14:23:37 -05:00
|
|
|
Some(copy i) => process(i),
|
|
|
|
None => ()
|
2012-08-06 20:14:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|