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.
12 fn struct_example(mut a: A) {
14 match a { // OK, no access of borrowed data
21 fn indirect_struct_example(mut b: &mut A) {
23 match *b { // OK, no access of borrowed data
30 fn underscore_example(mut c: i32) {
32 match c { // OK, no access of borrowed data (or any data at all)
44 fn enum_example(mut e: E) {
46 E::V(ref mut x, _) => x,
49 match e { // Don't know that E uses a tag for its discriminant
51 E::V(_, r) => (), //~ ERROR
57 fn indirect_enum_example(mut f: &mut E) {
59 E::V(ref mut x, _) => x,
62 match f { // Don't know that E uses a tag for its discriminant
64 E::V(_, r) => (), //~ ERROR
70 fn match_on_muatbly_borrowed_ref(mut p: &bool) {
72 match *p { // OK, no access at all
79 fn match_on_borrowed(mut t: bool) {