Skip to content

3-tuple gets inferred to internal test runner types with --test if certain type is marked Send #21080

Closed
@huonw

Description

@huonw
// wtf-testrunner.rs

#![allow(unstable)]

pub fn join<J: ToJoin<T>, T: Send /* WTF */>(_: J) -> Future<T> {
    unimplemented!()
}
pub trait ToJoin<T> {}

impl<A1, T1, A2, T2> ToJoin<(T1, T2)> for (A1, A2) {}

impl<A1, T1, A2, T2, A3, T3> ToJoin<(T1, T2, T3)> for (A1, A2, A3) {}
impl<A1, T1, A2, T2, A3, T3, A4, T4> ToJoin<(T1, T2, T3, T4)> for (A1, A2, A3, A4) {}

pub struct Future<T>;

pub fn all_ok() {
    let f1 = Future::<i32>;
    let f2 = Future::<i32>;

    let _: Future<(i32, i32)> = join((f1, f2));
}
pub fn also_ok() {
    let f1 = Future::<i32>;
    let f2 = Future::<i32>;
    let f3 = Future::<i32>;
    let f4 = Future::<i32>;

    let _: Future<(i32, i32, i32, i32)> = join((f1, f2, f3, f4));
}

pub fn wtf() {
    let f1 = Future::<i32>;
    let f2 = Future::<i32>;
    let f3 = Future::<i32>;

    let _: Future<(i32, i32, i32)> = join((f1, f2, f3));
}

fn main() {}

Compiling with rustc wtf-testrunner.rs works fine, rustc --test wtf-testrunner.rs definitely does not, though:

wtf-testrunner.rs:35:38: 35:56 error: mismatched types: expected `Future<(i32, i32, i32)>`, found `Future<(test::TestDesc, test::TestResult, collections::vec::Vec<u8>)>` (expected i32, found struct test::TestDesc)
wtf-testrunner.rs:35     let _: Future<(i32, i32, i32)> = join((f1, f2, f3));
                                                          ^~~~~~~~~~~~~~~~~~
error: aborting due to previous error

And, if the Send bound in join is removed, the code compiles fine with or without --test.

So... somehow the test runner is causing a tuple of arity 3 specifically to be inferred to something completely ridiculous.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions