Skip to content

Unsized coercions for method call receivers #2670

@flodiebold

Description

@flodiebold

We currently don't complete or infer slice method calls on arrays:

fn test() {
    let arr = [1, 2, 3];
    arr.len(); // doesn't work
}

These work because Rust performs (only) unsized coercions on method call receiver, so [i32; 3] gets automatically coerced to [i32]. We have some support for these coercions, but don't perform them for method call receivers yet (I wasn't even aware that this was happening until I started wondering where these array methods come from 🙂 ). Implementing this will require some care, since method resolution is already quite complicated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions