about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-25 04:48:19 +0000
committerbors <bors@rust-lang.org>2015-08-25 04:48:19 +0000
commit656c3acdebb6334b82e3e11251dca6d43406e269 (patch)
tree3f6da9d5e89f7971eaf384b715436c8ec791a079
parent19aadd51a89f8d6f706e1eabd746039a748fa9e6 (diff)
parent528d99c014f551f44892e65058798c8c2f59ac74 (diff)
downloadrust-656c3acdebb6334b82e3e11251dca6d43406e269.tar.gz
rust-656c3acdebb6334b82e3e11251dca6d43406e269.zip
Auto merge of #27966 - GuillaumeGomez:iterator, r=alexcrichton
Part of #22709.
cc @Veedrac

r? @bluss

I don't have added tests yet, I'll see how to do it tomorrow.
-rw-r--r--src/libstd/sys/common/net.rs3
-rw-r--r--src/test/run-pass/sync-send-in-std.rs31
2 files changed, 34 insertions, 0 deletions
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs
index 68d5f49dffa..67e1099c295 100644
--- a/src/libstd/sys/common/net.rs
+++ b/src/libstd/sys/common/net.rs
@@ -110,6 +110,9 @@ impl Iterator for LookupHost {
     }
 }
 
+unsafe impl Sync for LookupHost {}
+unsafe impl Send for LookupHost {}
+
 impl Drop for LookupHost {
     fn drop(&mut self) {
         unsafe { freeaddrinfo(self.original) }
diff --git a/src/test/run-pass/sync-send-in-std.rs b/src/test/run-pass/sync-send-in-std.rs
new file mode 100644
index 00000000000..85ab59a2983
--- /dev/null
+++ b/src/test/run-pass/sync-send-in-std.rs
@@ -0,0 +1,31 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(lookup_host)]
+
+use std::net::lookup_host;
+
+fn is_sync<T>(_: T) where T: Sync {}
+fn is_send<T>(_: T) where T: Send {}
+
+macro_rules! all_sync_send {
+    ($ctor:expr, $($iter:ident),+) => ({
+        $(
+            let mut x = $ctor;
+            is_sync(x.$iter());
+            let mut y = $ctor;
+            is_send(y.$iter());
+        )+
+    })
+}
+
+fn main() {
+    all_sync_send!(lookup_host("localhost").unwrap(), next);
+}