Skip to content

Bad compilation error when Send bound is required but not met #18988

Closed
@carllerche

Description

@carllerche

Here is an example. The error message only tells me that Send is required but not present. The Send bound is implicit though, and is missing due to something in my code. It would be nice if the compiler could tell me what is preventing the Send bound.

Error

bounds.rs:8:1: 9:2 error: the trait `core::kinds::Send` is not implemented for the type `MyFoo`
bounds.rs:8 impl Foo for MyFoo {
bounds.rs:9 }
bounds.rs:8:1: 9:2 note: the trait `core::kinds::Send` must be implemented because it is required by `Foo`
bounds.rs:8 impl Foo for MyFoo {
bounds.rs:9 }
error: aborting due to previous error
➜  rust-exp  rustc bounds.rs
bounds.rs:5:5: 5:33 warning: struct field is never used: `children`, #[warn(dead_code)] on by default
bounds.rs:5     children: Vec<Box<Foo+Send>>,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Code

pub trait Foo : Send {
}

pub struct MyFoo {
    children: Vec<Box<Foo>>,
}

impl Foo for MyFoo {
}

pub fn main() {
}

@nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions