Skip to content

negative impls cause problems with type inference #74383

Closed
@lcnr

Description

@lcnr
#![feature(negative_impls)]

struct Foo<T>(T);

impl !Send for Foo<()> {}

fn test<T>() -> T where Foo<T>: Send { todo!() }

fn main() {
    let _: u8 = test();
}

Fails with

error[E0277]: `Foo<_>` cannot be sent between threads safely
  --> $DIR/fk.rs:10:17
   |
LL | fn test<T>() -> T where Foo<T>: Send { todo!() }
   |                                 ---- required by this bound in `test`
...
LL |     let _: u8 = test();
   |                 ^^^^ `Foo<_>` cannot be sent between threads safely
   |
   = help: the trait `std::marker::Send` is not implemented for `Foo<_>`

Explicitly specifying test::<u8>() works though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceC-bugCategory: This is a bug.F-negative_impls#![feature(negative_impls)]requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions