Skip to content

Wrong error location when slicing a slice #101796

Closed
@Bunch-of-cells

Description

@Bunch-of-cells
fn main() {
    let s = &[0, 1];
    let _ = &s[0..4];
}

The current output is:

thread 'main' panicked at 'range end index 4 out of range for slice of length 2', library/core/src/slice/index.rs:73:5

Ideally the output should look like:

thread 'main' panicked at 'range end index 4 out of range for slice of length 2', src/main.rs:3:21

The error location should be in main.rs, and not library/core/.../index.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions