Skip to content

type-mismatch false positive on unsizing coercion #13864

@jDomantas

Description

@jDomantas

rust-analyzer version: rust-analyzer version: 0.3.1334-standalone (74ae2dd 2022-12-25)

rustc version: rustc 1.66.0 (69f9c33d7 2022-12-12)

relevant settings: in vscode's settings.json: "rust-analyzer.diagnostics.experimental.enable": true, "rust-analyzer.checkOnSave.enable": false (to opt-in into type checking diagnostics)

This code:

struct Foo<T: ?Sized> {
    leading: u32,
    trailing: T,
}

fn unsize(x: Box<Foo<[u32; 4]>>) -> Box<Foo<[u32]>> {
    x
}

compiles fine with rustc, but vscode shows type error from rust-analyzer:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bugS-unactionableIssue requires feedback, design decisions or is blocked on other work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions