1 // Issue #53114: NLL's borrow check had some deviations from the old borrow
2 // checker, and both had some deviations from our ideal state. This test
3 // captures the behavior of how `_` bindings are handled with respect to how we
4 // flag expressions that are meant to request unsafe blocks.
5 #![allow(irrefutable_let_patterns)]
8 fn let_wild_gets_moved_expr() {
11 let _ = m; // accepted, and want it to continue to be
13 let mm = (M, M); // variation on above with `_` in substructure
19 fn match_moved_expr_to_wild() {
22 match m { _ => { } } // #53114: should eventually be accepted too
25 let mm = (M, M); // variation on above with `_` in substructure
26 match mm { (_x, _) => { } }
27 match mm { (_, _y) => { } }
29 match mm { (_, _) => { } }
33 fn if_let_moved_expr_to_wild() {
36 if let _ = m { } // #53114: should eventually be accepted too
39 let mm = (M, M); // variation on above with `_` in substructure
40 if let (_x, _) = mm { }
41 if let (_, _y) = mm { }
43 if let (_, _) = mm { }
47 fn let_wild_gets_borrowed_expr() {
50 let _ = m; // accepted, and want it to continue to be
51 // let _x = m; // (compare with this error.)
54 let mut mm = (M, M); // variation on above with `_` in substructure
55 let (r1, r2) = (&mut mm.0, &mut mm.1);
60 fn match_borrowed_expr_to_wild() {
63 match m { _ => {} } ; // accepted, and want it to continue to be
66 let mut mm = (M, M); // variation on above with `_` in substructure
67 let (r1, r2) = (&mut mm.0, &mut mm.1);
68 match mm { (_, _) => { } }
72 fn if_let_borrowed_expr_to_wild() {
75 if let _ = m { } // accepted, and want it to continue to be
78 let mut mm = (M, M); // variation on above with `_` in substructure
79 let (r1, r2) = (&mut mm.0, &mut mm.1);
80 if let (_, _) = mm { }