Closed
Description
I tried this code:
fn main() {
let array = [0x42u8; 10];
for b in &array {
let lo = b & 0xf;
let hi = (b >> 4) & 0xf;
}
}
I expected to see this happen: it should be compiled
Instead, this happened:
error[E0277]: no implementation for `u8 & i32`
--> src/main.rs:5:27
|
5 | let hi = (b >> 4) & 0xf;
| ^ no implementation for `u8 & i32`
|
= help: the trait `std::ops::BitAnd<i32>` is not implemented for `u8`
Meta
rustc --version --verbose
:
rustc 1.41.0 (5e1a79984 2020-01-27)
binary: rustc
commit-hash: 5e1a799842ba6ed4a57e91f7ab9435947482f7d8
commit-date: 2020-01-27
host: x86_64-unknown-linux-gnu
release: 1.41.0
LLVM version: 9.0
The same happens on beta and nightly.
Backtrace
Compiling playground v0.0.1 (/playground)
error[E0277]: no implementation for `u8 & i32`
--> src/main.rs:5:27
|
5 | let hi = (b >> 4) & 0xf;
| ^ no implementation for `u8 & i32`
|
= help: the trait `std::ops::BitAnd<i32>` is not implemented for `u8`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.