Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kind bounds specified as supertraits don't propagate through trait objects. #17604

Closed
sfackler opened this issue Sep 28, 2014 · 1 comment
Closed
Labels
A-type-system Area: Type system

Comments

@sfackler
Copy link
Member

trait Foo: Send {}

impl Foo for Box<Foo> {}

fn main() {}
test.rs:3:1: 3:25 error: the trait `core::kinds::Send` is not implemented for the type `Box<Foo+'static>`
test.rs:3 impl Foo for Box<Foo> {}
          ^~~~~~~~~~~~~~~~~~~~~~~~
test.rs:3:1: 3:25 note: the trait `core::kinds::Send` must be implemented because it is required by `Foo`
test.rs:3 impl Foo for Box<Foo> {}
          ^~~~~~~~~~~~~~~~~~~~~~~~

or similarly

trait Foo: Send {}

struct Bar(Box<Foo>);

fn test() {
    fn is_send<U: Send>() {}
    is_send::<Bar>()
}

fn main() {}
test.rs:7:5: 7:19 error: the trait `core::kinds::Send` is not implemented for the type `Bar`
test.rs:7     is_send::<Bar>()
              ^~~~~~~~~~~~~~
test.rs:7:5: 7:19 note: the trait `core::kinds::Send` must be implemented because it is required by `test::is_send`
test.rs:7     is_send::<Bar>()
              ^~~~~~~~~~~~~~
error: aborting due to previous error

The compiler correctly tracks the Send kind in other contexts. This properly compiles, for example:

trait Foo: Send {}

fn test<T: Foo>() {
    fn is_send<U: Send>() {}
    is_send::<T>()
}
@sfackler sfackler added A-type-system Area: Type system I-wrong labels Sep 28, 2014
@huonw
Copy link
Member

huonw commented Oct 4, 2014

Dupe of #15155.

@huonw huonw closed this as completed Oct 4, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

2 participants