Skip to content

Confusing error message with boxed unsized types #17122

Closed
@ftxqxd

Description

@ftxqxd
struct Foo<Sized? T>;

impl<Sized? T> Foo<T> {
    fn frob(self, bar: Box<T>) {}
}

fn main() {
    let foo: Foo<Num> = Foo;
    foo.frob(box 1i as Box<Num>);
}

yields the error

dstbug.rs:9:14: 9:32 error: mismatched types: expected `Box<core::num::Num>`, found `Box<core::num::Num>` (expected box, found box)
dstbug.rs:9     foo.frob(box 1i as Box<Num>);
                         ^~~~~~~~~~~~~~~~~~
error: aborting due to previous error

cc @nick29581

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-DSTsArea: Dynamically-sized types (DSTs)A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions