Skip to content

ops::Range::end out of range (overflowing_literals) #47213

Closed
@hellow554

Description

@hellow554

I would expect that the the following prints would lead to the same result, instead rust complains about 256 being out of range for u8, which is correct, but because end is exclusive, it should't complain.

#![feature(inclusive_range_syntax)]

fn main() {
    let range_a = 0..256;
    let range_b = 0..=255;
    
    println!("{:?}", range_a.collect::<Vec<u8>>());
    println!("{:?}", range_b.collect::<Vec<u8>>());
}

PlayGround

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions