From 2551adb4f1b127fd5bef4c2bb96fd361e4fcc0df Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 1 Feb 2023 11:17:32 +0100 Subject: refactor(tvix/nix-compat): operator precedence can trip the unwary 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 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/nix-compat/src/nixbase32.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tvix/nix-compat') 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 -- cgit 1.4.1