]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/binding/issue-53114-safety-checks.rs
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.
6 #![feature(untagged_unions)]
11 union U { a: I, b: F }
19 fn let_wild_gets_unsafe_field() {
20 let u1
= U { a: I(0) }
;
21 let u2
= U { a: I(1) }
;
22 let p
= P { a: &2, b: &3 }
;
23 let _
= &p
.b
; //~ WARN E0133
24 //~^ WARN will become a hard error
25 let _
= u1
.a
; // #53114: should eventually signal error as well
26 let _
= &u2
.a
; //~ ERROR [E0133]
28 // variation on above with `_` in substructure
29 let (_
,) = (&p
.b
,); //~ WARN E0133
30 //~^ WARN will become a hard error
31 let (_
,) = (u1
.a
,); //~ ERROR [E0133]
32 let (_
,) = (&u2
.a
,); //~ ERROR [E0133]
35 fn match_unsafe_field_to_wild() {
36 let u1
= U { a: I(0) }
;
37 let u2
= U { a: I(1) }
;
38 let p
= P { a: &2, b: &3 }
;
39 match &p
.b { _ => { }
} //~ WARN E0133
40 //~^ WARN will become a hard error
41 match u1
.a { _ => { }
} //~ ERROR [E0133]
42 match &u2
.a { _ => { }
} //~ ERROR [E0133]
44 // variation on above with `_` in substructure
45 match (&p
.b
,) { (_,) => { }
} //~ WARN E0133
46 //~^ WARN will become a hard error
47 match (u1
.a
,) { (_,) => { }
} //~ ERROR [E0133]
48 match (&u2
.a
,) { (_,) => { }
} //~ ERROR [E0133]