1 // Test that a (partially) mutably borrowed place can be matched on, so long as
2 // we don't have to read any values that are mutably borrowed to determine
5 // Test that we don't allow mutating the value being matched on in a way that
6 // changes which patterns it matches, until we have chosen an arm.
10 fn struct_example(mut a: A) {
12 match a { // OK, no access of borrowed data
19 fn indirect_struct_example(mut b: &mut A) {
21 match *b { // OK, no access of borrowed data
28 fn underscore_example(mut c: i32) {
30 match c { // OK, no access of borrowed data (or any data at all)
42 fn enum_example(mut e: E) {
44 E::V(ref mut x, _) => x,
47 match e { // Don't know that E uses a tag for its discriminant
49 E::V(_, r) => (), //~ ERROR
55 fn indirect_enum_example(mut f: &mut E) {
57 E::V(ref mut x, _) => x,
60 match f { // Don't know that E uses a tag for its discriminant
62 E::V(_, r) => (), //~ ERROR
68 fn match_on_muatbly_borrowed_ref(mut p: &bool) {
70 match *p { // OK, no access at all
77 fn match_on_borrowed(mut t: bool) {