Skip to content

Bitwise shift operator doesn't cast shift amount #1234

@bjorn3

Description

@bjorn3

I tried this code:

fn foo() {
    1u8 << 2u32;
}

I expected to see this happen: The shift amount gets casted as necessary to allow this.

Instead, this happened:

<source>:2:12: error: expected [u8] got [u32]
    2 |     1u8 << 2u32;
      |     ~      ^
Compiler returned: 1

Meta

  • What version of Rust GCC were you using, git sha if possible.
    gccrs (Compiler-Explorer-Build-gcc-74e836599ce80a11b1fe28065ed7aae6ffa3b7e2-binutils-2.38) 12.0.1 20220118 (experimental)
    

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions