Skip to content

str::get isn't overflow-checked with InclusiveRange #42401

Description

@scottmcm

Repro: https://is.gd/lVsdTA

#![feature(inclusive_range_syntax)]
#![feature(str_checked_slicing)]

fn main(){
    println!("{:?}", &"hello".get(...usize::max_value()-1)); // None
    println!("{:?}", &"hello".get(...usize::max_value())); // Some("")
}

(The latter with [] correctly panics with "attempted to index str up to maximum usize".)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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