]> git.lizzy.rs Git - rust.git/blob - tests/pretty/block-disambig.rs
Rollup merge of #106106 - jyn514:remote-tracking-branch, r=Mark-Simulacrum
[rust.git] / tests / pretty / block-disambig.rs
1 // compile-flags: --crate-type=lib
2
3 // A bunch of tests for syntactic forms involving blocks that were
4 // previously ambiguous (e.g., 'if true { } *val;' gets parsed as a
5 // binop)
6
7
8 use std::cell::Cell;
9
10 fn test1() { let val = &0; { } *val; }
11
12 fn test2() -> isize { let val = &0; { } *val }
13
14 #[derive(Copy, Clone)]
15 struct S { eax: isize }
16
17 fn test3() {
18     let regs = &Cell::new(S {eax: 0});
19     match true { true => { } _ => { } }
20     regs.set(S {eax: 1});
21 }
22
23 fn test4() -> bool { let regs = &true; if true { } *regs || false }
24
25 fn test5() -> (isize, isize) { { } (0, 1) }
26
27 fn test6() -> bool { { } (true || false) && true }
28
29 fn test7() -> usize {
30     let regs = &0;
31     match true { true => { } _ => { } }
32     (*regs < 2) as usize
33 }
34
35 fn test8() -> isize {
36     let val = &0;
37     match true {
38         true => { }
39         _    => { }
40     }
41     if *val < 1 {
42         0
43     } else {
44         1
45     }
46 }
47
48 fn test9() {
49     let regs = &Cell::new(0);
50     match true { true => { } _ => { } } regs.set(regs.get() + 1);
51 }
52
53 fn test10() -> isize {
54     let regs = vec![0];
55     match true { true => { } _ => { } }
56     regs[0]
57 }
58
59 fn test11() -> Vec<isize> { if true { } vec![1, 2] }