Skip to content

What's the reasoning for E0225? #32220

@sgrif

Description

@sgrif

The following code fails to compile:

trait Foo {}
trait Bar {}

fn main() {
    let x: Box<Foo + Bar> = unimplemented!();
}

You can only box multiple traits when the additional bounds are built in. This seems like an extremely odd restriction. Is there an intention to remove it at some point? The workaround is incredibly annoying:

trait Foo {}
trait Bar {}

trait FooAndBar: Foo + Bar {}
impl<T> FooAndBar for T where T: Foo + Bar {}

fn main() {
    let x: Box<FooAndBar> = unimplemented!();
}

The number of these traits grows quite rapidly as you need multiple combinations of various traits. In Diesel's case, many of these will end up needing to be part of the public API which is leading to a lot of confusing and hard to discover types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions