Closed
Description
#![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.
Activity
eddyb commentedon Jul 15, 2020
cc @nikomatsakis @matthewjasper (I suspect this might actually be expected, but I'm not sure)
lcnr commentedon Jul 16, 2020
Seems like this is caused by a mixture of
rust/src/librustc_trait_selection/traits/select/candidate_assembly.rs
Lines 137 to 141 in 6ee1b62
and
rust/src/librustc_trait_selection/traits/select/mod.rs
Lines 937 to 941 in 6ee1b62
We might be able to deal with this by also updating
candidate_should_be_dropped_in_favor_of
.Let's see if the current behavior is expected before looking deeper into this.
nikomatsakis commentedon Jul 16, 2020
Hmm I don't think this is expected, though I still don't quite understand how it happens.
lcnr commentedon Jul 21, 2020
closing as intended behavior, see #74525 (comment) for more details
It looks to me like preventing the impl for
Foo<()>
is directly tracked in #13231.