Skip to content

object_safe_for_dispatch: auto trait bounds #91

Open
@lcnr

Description

@lcnr
#![feature(object_safe_for_dispatch)]
trait Trait {
    fn not_object_safe() {}
}

fn impls_send<T: Send + ?Sized>() {}

fn main() {
    impls_send::<dyn Trait + Send>();
}

passes with the old solver, but results in an error with new:

error[E0277]: `dyn Trait + Send` cannot be sent between threads safely
  --> <source>:10:18
   |
10 |     impls_send::<dyn Trait + Send>();
   |                  ^^^^^^^^^^^^^^^^ `dyn Trait + Send` cannot be sent between threads safely
   |
   = help: the trait `Send` is not implemented for `dyn Trait + Send`
note: required by a bound in `impls_send`
  --> <source>:7:18
   |
7  | fn impls_send<T: Send + ?Sized>() {}
   |                  ^^^^ required by this bound in `impls_send`

unsure whether this is desired or not, it does not match the old solver. Caused by https://github.com/rust-lang/rust/blob/bdc15928c8119a86d15e2946cb54851264607842/compiler/rustc_trait_selection/src/solve/assembly/mod.rs#L793-L795

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions