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 test1()10fn test1() { let val = &0; { } *val; } 11 test2() -> isize12fn test2() -> isize { let val = &0; { } *val } 13 14 #[derive(Copy, Clone)] 15 struct S { eax: isize } 16 test3()17fn test3() { 18 let regs = &Cell::new(S {eax: 0}); 19 match true { true => { } _ => { } } 20 regs.set(S {eax: 1}); 21 } 22 test4() -> bool23fn test4() -> bool { let regs = &true; if true { } *regs || false } 24 test5() -> (isize, isize)25fn test5() -> (isize, isize) { { } (0, 1) } 26 test6() -> bool27fn test6() -> bool { { } (true || false) && true } 28 test7() -> usize29fn test7() -> usize { 30 let regs = &0; 31 match true { true => { } _ => { } } 32 (*regs < 2) as usize 33 } 34 test8() -> isize35fn 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 test9()48fn test9() { 49 let regs = &Cell::new(0); 50 match true { true => { } _ => { } } regs.set(regs.get() + 1); 51 } 52 test10() -> isize53fn test10() -> isize { 54 let regs = vec![0]; 55 match true { true => { } _ => { } } 56 regs[0] 57 } 58 test11() -> Vec<isize>59fn test11() -> Vec<isize> { if true { } vec![1, 2] } 60