]>
git.proxmox.com Git - rustc.git/blob - tests/ui/closures/old-closure-expr-precedence.rs
3 #![allow(unused_must_use)]
4 #![allow(unused_parens)]
5 // This test has some extra semis in it that the pretty-printer won't
6 // reproduce so we don't want to automatically reformat it
13 * When you write a block-expression thing followed by
14 * a lone unary operator, you can get a surprising parse:
24 * These will parse as subtraction and multiplication binops.
25 * To get them to parse "the way you want" you need to brace
31 * or alternatively, semi-separate them:
36 * This seems a little wonky, but the alternative is to lower
37 * precedence of such block-like exprs to the point where
38 * you have to parenthesize them to get them to occur in the
39 * RHS of a binop. For example, you'd have to write:
41 * 12 + (if (foo) { 13 } else { 14 });
45 * 12 + if (foo) { 13 } else { 14 };
47 * Since we want to maintain the ability to write the latter,
48 * we leave the parens-burden on the trailing unop case.
56 assert_eq
!(if (true) { 12 }
else { 12 }
- num
, 0);
57 assert_eq
!(12 - if (true) { 12 }
else { 12 }
, 0);
58 if (true) { 12; } {-num}
;
59 if (true) { 12; }
; {-num}
;
60 if (true) { 12; }
;;; -num
;
61 //~^ WARNING unnecessary trailing semicolons