Skip to content

Wrong error location when slicing a slice #101796

Closed

Description

@bunchofcellulose
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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 14, 2022
  2. fmease commented on Sep 14, 2022

    @fmease
    Member

    This should already be fixed on nightly via #100759. Can you confirm this? This issue is probably a duplicate of #100696.

  3. compiler-errors commented on Sep 15, 2022

    @compiler-errors
    Contributor

    This is indeed fixed on nightly. Thanks for reporting the issue, closing now!

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

    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