about summary refs log tree commit diff
path: root/tvix/nix-compat/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-02-01T10·17+0100
committerclbot <clbot@tvl.fyi>2023-02-01T13·43+0000
commit2551adb4f1b127fd5bef4c2bb96fd361e4fcc0df (patch)
tree8b0cc827bee3953f20a3da5047cc16bacc6ebc33 /tvix/nix-compat/src
parent361ffd7903ab129657a7dcc37654f3c077321027 (diff)
refactor(tvix/nix-compat): operator precedence can trip the unwary r/5804
warning: operator precedence can trip the unwary
  --> nix-compat/src/nixbase32.rs:41:23
   |
41 |                 c |= ((input[i + 1] as u16) << 8 - j as u16) as u8
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(input[i + 1] as u16) << (8 - j as u16)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
   = note: `#[warn(clippy::precedence)]` on by default

Change-Id: I091071d649abf4ed38f5f4e39a0c5d21a0459bff
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7996
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/nix-compat/src')
-rw-r--r--tvix/nix-compat/src/nixbase32.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/tvix/nix-compat/src/nixbase32.rs b/tvix/nix-compat/src/nixbase32.rs
index ad67601eeb1e..0c7843fc8982 100644
--- a/tvix/nix-compat/src/nixbase32.rs
+++ b/tvix/nix-compat/src/nixbase32.rs
@@ -38,7 +38,7 @@ pub fn encode(input: &[u8]) -> String {
                 // we want to right shift, and discard shifted out bits (unchecked)
                 // To do this without panicing, we need to do the shifting in u16
                 // and convert back to u8 afterwards.
-                c |= ((input[i + 1] as u16) << 8 - j as u16) as u8
+                c |= ((input[i + 1] as u16) << (8 - j as u16)) as u8
             }
 
             output