-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Metadata
Metadata
Assignees
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.