Skip to content

Should have a lint for statically detectable overlong bit shifts #17713

Closed
@ben0x539

Description

@ben0x539

Currently overlong bit shifts are undefined behavior because that's how llvm rolls--#10183. But even when they aren't, we should warn on something like x << 24 where x happens to be u8, since it's a useless operation that couldn't possibly return anything interesting.

There's a motivating example and I imagine it'd be a common gotcha since other languages tend to read unadorned integral literals as 32bit ints and then promote the x in x << 24 before doing the actual shift.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions