]> git.lizzy.rs Git - rust.git/blob - tests/ui/expr-block.rs
Rollup merge of #106648 - Nilstrieb:poly-cleanup, r=compiler-errors
[rust.git] / tests / ui / expr-block.rs
1 // run-pass
2 #![allow(unused_braces)]
3 #![allow(dead_code)]
4
5 // Tests for standalone blocks as expressions
6
7 fn test_basic() { let rs: bool = { true }; assert!((rs)); }
8
9 struct RS { v1: isize, v2: isize }
10
11 fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; assert_eq!(rs.v2, 20); }
12
13 fn test_filled_with_stuff() {
14     let rs = { let mut a = 0; while a < 10 { a += 1; } a };
15     assert_eq!(rs, 10);
16 }
17
18 pub fn main() { test_basic(); test_rec(); test_filled_with_stuff(); }