Modified the tests so that if we place wrong parentheses we will get a different result
This commit is contained in:
parent
66e212b544
commit
120b84125e
3 changed files with 16 additions and 16 deletions
|
|
@ -20,10 +20,10 @@ fn main() {
|
|||
1 ^ (1 - 1);
|
||||
3 | (2 - 1);
|
||||
3 & (5 - 2);
|
||||
12 & (0xF000 << 4);
|
||||
12 & (0xF000 >> 4);
|
||||
(12 << 4) ^ 0xF000;
|
||||
(12 << 4) | 0xF000;
|
||||
0x0F00 & (0x00F0 << 4);
|
||||
0x0F00 & (0xF000 >> 4);
|
||||
(0x0F00 << 1) ^ 3;
|
||||
(0x0F00 << 1) | 2;
|
||||
|
||||
let b = 3;
|
||||
trip!(b * 8);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ fn main() {
|
|||
1 ^ 1 - 1;
|
||||
3 | 2 - 1;
|
||||
3 & 5 - 2;
|
||||
12 & 0xF000 << 4;
|
||||
12 & 0xF000 >> 4;
|
||||
12 << 4 ^ 0xF000;
|
||||
12 << 4 | 0xF000;
|
||||
0x0F00 & 0x00F0 << 4;
|
||||
0x0F00 & 0xF000 >> 4;
|
||||
0x0F00 << 1 ^ 3;
|
||||
0x0F00 << 1 | 2;
|
||||
|
||||
let b = 3;
|
||||
trip!(b * 8);
|
||||
|
|
|
|||
|
|
@ -46,26 +46,26 @@ LL | 3 & 5 - 2;
|
|||
error: operator precedence can trip the unwary
|
||||
--> tests/ui/precedence.rs:23:5
|
||||
|
|
||||
LL | 12 & 0xF000 << 4;
|
||||
| ^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `12 & (0xF000 << 4)`
|
||||
LL | 0x0F00 & 0x00F0 << 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `0x0F00 & (0x00F0 << 4)`
|
||||
|
||||
error: operator precedence can trip the unwary
|
||||
--> tests/ui/precedence.rs:24:5
|
||||
|
|
||||
LL | 12 & 0xF000 >> 4;
|
||||
| ^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `12 & (0xF000 >> 4)`
|
||||
LL | 0x0F00 & 0xF000 >> 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `0x0F00 & (0xF000 >> 4)`
|
||||
|
||||
error: operator precedence can trip the unwary
|
||||
--> tests/ui/precedence.rs:25:5
|
||||
|
|
||||
LL | 12 << 4 ^ 0xF000;
|
||||
| ^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(12 << 4) ^ 0xF000`
|
||||
LL | 0x0F00 << 1 ^ 3;
|
||||
| ^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(0x0F00 << 1) ^ 3`
|
||||
|
||||
error: operator precedence can trip the unwary
|
||||
--> tests/ui/precedence.rs:26:5
|
||||
|
|
||||
LL | 12 << 4 | 0xF000;
|
||||
| ^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(12 << 4) | 0xF000`
|
||||
LL | 0x0F00 << 1 | 2;
|
||||
| ^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(0x0F00 << 1) | 2`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue