Skip to content

Redundant trait bounds aren't ignored when checking if a trait object implements a trait #19629

@sfackler

Description

@sfackler

This program doesn't compile:

trait Foo: Send + Sync {}

impl Foo for int {}

impl Foo for Box<Foo> {}

fn f<F: Foo>(_: F) {}

fn main() {
    let foo: Box<Foo+Send+Sync> = box 10i;
    f(foo)
}
test.rs:11:5: 11:6 error: the trait `Foo` is not implemented for the type `Box<Foo+Send+Sync>`
test.rs:11     f(foo)
               ^
test.rs:11:5: 11:6 note: the trait `Foo` must be implemented because it is required by `f`
test.rs:11     f(foo)
               ^
error: aborting due to previous error

I would expect that Box<Foo> would be the same type as Box<Foo+Send+Sync> because Foo requires Send+Sync.

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