]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/control-flow/short-circuit-let.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / src / test / ui / consts / control-flow / short-circuit-let.rs
1 // `&&` and `||` were previously forbidden in constants alongside let bindings.
2
3 // run-pass
4
5 #![feature(const_panic)]
6
7 const X: i32 = {
8 let mut x = 0;
9 let _ = true && { x = 1; false };
10 x
11 };
12
13 const Y: bool = {
14 let x = true && false || true;
15 x
16 };
17
18 const fn truthy() -> bool {
19 let x = true || return false;
20 x
21 }
22
23 const fn falsy() -> bool {
24 let x = true && return false;
25 x
26 }
27
28 fn main() {
29 const _: () = assert!(Y);
30 assert!(Y);
31
32 const _: () = assert!(X == 1);
33 assert_eq!(X, 1);
34
35 const _: () = assert!(truthy());
36 const _: () = assert!(!falsy());
37 assert!(truthy() && !falsy());
38 }