-
Notifications
You must be signed in to change notification settings - Fork 13.3k
3-tuple gets inferred to internal test runner types with --test if certain type is marked Send #21080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @nikomatsakis, I guess? |
@klutzy points out that specifically having |
cc me |
FYI: @carllerche discovered this problem while working on https://github.com/carllerche/syncbox |
Slightly more minimized: extern crate test;
struct Future<T>;
fn join<J: ToJoin<T>, T: Send>(_: J) -> Future<T> { }
trait ToJoin<T> { }
impl <A1, T1, A2, T2, A3, T3> ToJoin<(T1, T2, T3)> for (A1, A2, A3) { }
fn main() {
let _: Future<(i32, i32, i32)> = join((0, 0, 0));
}
|
This causes the problem. |
struct MyStruct;
// this will cause issue for 2-tuple
unsafe impl Send for (MyStruct, MyStruct) {}
// error: mismatched types: expected `Future<(i32, i32)>`, found `Future<(MyStruct, MyStruct)>`
let _: Future<(i32, i32)> = join((f1, f2));
// no error
let _: Future<(i32, i32)> = join::<(Future<i32>, Future<i32>), (i32, i32)>((f1, f2));
// uncommenting the two lines resolves the error.
// struct MyStruct2;
// unsafe impl Send for (MyStruct2, MyStruct2) {} |
I'll take a look at it. |
In fact, I think that the |
(I think there was language about specifically this in the OIBIT RFC) |
I agree with @nikomatsakis comments here and after a quick chat on IRC with him, we agreed that implementations of built-in traits (and likely default trait impls in the future) should be allowed just on |
Fixes rust-lang#21080 r? @nikomatsakis [breaking-change]
Compiling with
rustc wtf-testrunner.rs
works fine,rustc --test wtf-testrunner.rs
definitely does not, though:And, if the
Send
bound injoin
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.
The text was updated successfully, but these errors were encountered: