Skip to content

split_at_mut should #[track_caller] #83378

Closed
@ruza-net

Description

@ruza-net

When split_at_mut is called with mid > len, an internal assertion fails. However, it doesn't track its caller, so RUST_BACKTRACE=1 is required to determine the call site.

I tried this code:

fn main() {
    let mut x = [1];
    
    x.split_at_mut(2);
}

I expected to see this happen:

An error of the form thread 'main' panicked at 'split index (is 2) should be <= len (is 1)'.

Instead, this happened:

thread 'main' panicked at 'assertion failed: mid <= self.len()', /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/slice/mod.rs:1279:9

Meta

This occurs on stable (1.50.0), beta (1.51.0-beta.8) and nightly (1.53.0-nightly 2021-03-21).

Tested on playground.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libs-apiRelevant to the library API 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