Skip to content

Implicit trait object coercion doesn't work through arrays #11205

Closed
@sfackler

Description

@sfackler
trait Foo {}

impl Foo for int {}

fn foo(_: &[&Foo]) {}

fn main() {
    foo([&1i, &2i]);
}

fails to compile:

test.rs:8:8: 8:18 error: mismatched types: expected `&[&Foo<no-bounds>]` but found `[&int, .. 2]` (expected trait Foo but found &-ptr)
test.rs:8     foo([&1i, &2i]);
                  ^~~~~~~~~~
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /Users/sfackler/rust/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /Users/sfackler/rust/rust/src/librustc/lib.rs:441

cc @luqmana, @pcwalton

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions