Skip to content

Integer hex literals should perhaps not consider signededness #10713

Closed
@alexcrichton

Description

@alexcrichton

I would not expect this code to produce a warning:

fn main() {
    let a: i8 = 0x20;
    assert!(a == 0xff);
}

Although the following warnings are printed

foo.rs:3:12: 3:21 warning: comparison is useless due to type limits, #[warn(type_limits)] on by default
foo.rs:3     assert!(a == 0xff);
                     ^~~~~~~~~
<std-macros>:36:4: 52:5 note: in expansion of assert!
foo.rs:3:4: 3:23 note: expansion site
foo.rs:3:17: 3:21 warning: literal out of range for its type, #[warn(type_overflow)] on by default
foo.rs:3     assert!(a == 0xff);
                          ^~~~
<std-macros>:36:4: 52:5 note: in expansion of assert!
foo.rs:3:4: 3:23 note: expansion site

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions