Skip to content

Commit

Permalink
Fix clippy::precedence warning
Browse files Browse the repository at this point in the history
```
error: operator precedence can trip the unwary
   --> tests/auxiliary/mod.rs:178:38
    |
178 |   const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
    |  ______________________________________^
179 | |     | ('l' as u64) << 48
180 | |     | ('p' as u64) << 40
181 | |     | ('r' as u64) << 32
182 | |     | ('o' as u64) << 24
183 | |     | ('f' as u64) << 16
184 | |     | ('r' as u64) << 8
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
    = note: `-D clippy::precedence` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::precedence)]`
help: consider parenthesizing your expression
    |
178 ~ const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
179 +     | ('l' as u64) << 48
180 +     | ('p' as u64) << 40
181 +     | ('r' as u64) << 32
182 +     | ('o' as u64) << 24
183 +     | ('f' as u64) << 16 | (('r' as u64) << 8)
    |

error: operator precedence can trip the unwary
   --> tests/auxiliary/mod.rs:178:38
    |
178 |   const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
    |  ______________________________________^
179 | |     | ('l' as u64) << 48
180 | |     | ('p' as u64) << 40
181 | |     | ('r' as u64) << 32
182 | |     | ('o' as u64) << 24
183 | |     | ('f' as u64) << 16
    | |________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
help: consider parenthesizing your expression
    |
178 ~ const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
179 +     | ('l' as u64) << 48
180 +     | ('p' as u64) << 40
181 +     | ('r' as u64) << 32
182 +     | ('o' as u64) << 24 | (('f' as u64) << 16)
    |

error: operator precedence can trip the unwary
   --> tests/auxiliary/mod.rs:178:38
    |
178 |   const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
    |  ______________________________________^
179 | |     | ('l' as u64) << 48
180 | |     | ('p' as u64) << 40
181 | |     | ('r' as u64) << 32
182 | |     | ('o' as u64) << 24
    | |________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
help: consider parenthesizing your expression
    |
178 ~ const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
179 +     | ('l' as u64) << 48
180 +     | ('p' as u64) << 40
181 +     | ('r' as u64) << 32 | (('o' as u64) << 24)
    |

error: operator precedence can trip the unwary
   --> tests/auxiliary/mod.rs:178:38
    |
178 |   const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
    |  ______________________________________^
179 | |     | ('l' as u64) << 48
180 | |     | ('p' as u64) << 40
181 | |     | ('r' as u64) << 32
    | |________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
help: consider parenthesizing your expression
    |
178 ~ const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
179 +     | ('l' as u64) << 48
180 +     | ('p' as u64) << 40 | (('r' as u64) << 32)
    |

error: operator precedence can trip the unwary
   --> tests/auxiliary/mod.rs:178:38
    |
178 |   const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
    |  ______________________________________^
179 | |     | ('l' as u64) << 48
180 | |     | ('p' as u64) << 40
    | |________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
help: consider parenthesizing your expression
    |
178 ~ const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
179 +     | ('l' as u64) << 48 | (('p' as u64) << 40)
    |

error: operator precedence can trip the unwary
   --> tests/auxiliary/mod.rs:178:38
    |
178 |   const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
    |  ______________________________________^
179 | |     | ('l' as u64) << 48
    | |________________________^ help: consider parenthesizing your expression: `((255_u64) << 56) | (('l' as u64) << 48)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
```
  • Loading branch information
taiki-e committed Dec 27, 2024
1 parent 255ba51 commit a618d32
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ pub(crate) fn perturb_one_header(workspace_root: &Path) -> Option<PathBuf> {
path
}

const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64) << 56
| ('l' as u64) << 48
| ('p' as u64) << 40
| ('r' as u64) << 32
| ('o' as u64) << 24
| ('f' as u64) << 16
| ('r' as u64) << 8
| (129_u64);
const INSTR_PROF_RAW_MAGIC_64: u64 = (255_u64 << 56)
| (('l' as u64) << 48)
| (('p' as u64) << 40)
| (('r' as u64) << 32)
| (('o' as u64) << 24)
| (('f' as u64) << 16)
| (('r' as u64) << 8)
| 129_u64;

fn perturb_header(path: &Path) {
let mut file = fs::OpenOptions::new().read(true).write(true).open(path).unwrap();
Expand Down

0 comments on commit a618d32

Please sign in to comment.