Skip to content

Deref coercion not working for Box<Trait> #22194

Open
@aturon

Description

@aturon

The following fails to compile:

trait Trait {}

fn takes_ref(t: &Trait) {}
fn takes_box(t: Box<Trait>) {
    takes_ref(&t)
}
fn main() { }

with

<anon>:5:15: 5:17 error: the trait `Trait` is not implemented for the type `Box<Trait>` [E0277]
<anon>:5     takes_ref(&t)
                       ^~

despite the Deref implementation here.

I believe this should work based on the RFC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.T-compilerRelevant to the compiler 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