Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Rollup of 6 pull requests #44222

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ impl Step for Src {
"src/libprofiler_builtins",
];
let std_src_dirs_exclude = [
"src/compiler-rt/test",
"src/libcompiler_builtins/compiler-rt/test",
"src/jemalloc/test/unit",
];

Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ impl Step for Openssl {
"i686-unknown-freebsd" => "BSD-x86-elf",
"i686-unknown-linux-gnu" => "linux-elf",
"i686-unknown-linux-musl" => "linux-elf",
"i686-unknown-netbsd" => "BSD-x86-elf",
"mips-unknown-linux-gnu" => "linux-mips32",
"mips64-unknown-linux-gnuabi64" => "linux64-mips64",
"mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
Expand Down
1 change: 1 addition & 0 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
ty::TyProjection(ref proj) => Some(proj.item_def_id),
ty::TyFnDef(def_id, ..) |
ty::TyClosure(def_id, ..) |
ty::TyGenerator(def_id, ..) |
ty::TyAnon(def_id, _) => Some(def_id),
_ => None
};
Expand Down
14 changes: 9 additions & 5 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,13 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {

.toggle-wrapper {
position: relative;
margin-top: 5px;
}

.toggle-wrapper.collapsed {
height: 1em;
height: 25px;
transition: height .2s;
margin-bottom: .6em;
}

.collapse-toggle > .inner {
Expand Down Expand Up @@ -704,14 +706,16 @@ span.since {
margin-top: 5px;
}

.variant + .toggle-wrapper > a {
margin-top: 5px;
}

.sub-variant, .sub-variant > h3 {
margin-top: 0 !important;
}

.toggle-label {
display: inline-block;
margin-left: 4px;
margin-top: 3px;
}

.enum > .toggle-wrapper + .docblock, .struct > .toggle-wrapper + .docblock {
margin-left: 30px;
margin-bottom: 20px;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ impl hash::Hash for SocketAddrV6 {
///
/// let stream = TcpStream::connect(("127.0.0.1", 443));
/// // or
/// let stream = TcpStream::connect("127.0.0.1.443");
/// let stream = TcpStream::connect("127.0.0.1:443");
/// // or
/// let stream = TcpStream::connect((Ipv4Addr::new(127, 0, 0, 1), 443));
/// ```
Expand Down
48 changes: 44 additions & 4 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,18 @@ impl TcpStream {
/// `addr` is an address of the remote host. Anything which implements
/// [`ToSocketAddrs`] trait can be supplied for the address; see this trait
/// documentation for concrete examples.
/// In case [`ToSocketAddrs::to_socket_addrs()`] returns more than one entry,
/// then the first valid and reachable address is used.
///
/// If `addr` yields multiple addresses, `connect` will be attempted with
/// each of the addresses until a connection is successful. If none of
/// the addresses result in a successful connection, the error returned from
/// the last connection attempt (the last address) is returned.
///
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
/// [`ToSocketAddrs::to_socket_addrs()`]:
/// ../../std/net/trait.ToSocketAddrs.html#tymethod.to_socket_addrs
///
/// # Examples
///
/// Open a TCP connection to `127.0.0.1:8080`:
///
/// ```no_run
/// use std::net::TcpStream;
///
Expand All @@ -129,6 +132,23 @@ impl TcpStream {
/// println!("Couldn't connect to server...");
/// }
/// ```
///
/// Open a TCP connection to `127.0.0.1:8080`. If the connection fails, open
/// a TCP connection to `127.0.0.1:8081`:
///
/// ```no_run
/// use std::net::{SocketAddr, TcpStream};
///
/// let addrs = [
/// SocketAddr::from(([127, 0, 0, 1], 8080)),
/// SocketAddr::from(([127, 0, 0, 1], 8081)),
/// ];
/// if let Ok(stream) = TcpStream::connect(&addrs[..]) {
/// println!("Connected to the server!");
/// } else {
/// println!("Couldn't connect to server...");
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn connect<A: ToSocketAddrs>(addr: A) -> io::Result<TcpStream> {
super::each_addr(addr, net_imp::TcpStream::connect).map(TcpStream)
Expand Down Expand Up @@ -557,16 +577,36 @@ impl TcpListener {
/// The address type can be any implementor of [`ToSocketAddrs`] trait. See
/// its documentation for concrete examples.
///
/// If `addr` yields multiple addresses, `bind` will be attempted with
/// each of the addresses until one succeeds and returns the listener. If
/// none of the addresses succeed in creating a listener, the error returned
/// from the last attempt (the last address) is returned.
///
/// [`local_addr`]: #method.local_addr
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
///
/// # Examples
///
/// Create a TCP listener bound to `127.0.0.1:80`:
///
/// ```no_run
/// use std::net::TcpListener;
///
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
/// ```
///
/// Create a TCP listener bound to `127.0.0.1:80`. If that fails, create a
/// TCP listener bound to `127.0.0.1:443`:
///
/// ```no_run
/// use std::net::{SocketAddr, TcpListener};
///
/// let addrs = [
/// SocketAddr::from(([127, 0, 0, 1], 80)),
/// SocketAddr::from(([127, 0, 0, 1], 443)),
/// ];
/// let listener = TcpListener::bind(&addrs[..]).unwrap();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<TcpListener> {
super::each_addr(addr, net_imp::TcpListener::bind).map(TcpListener)
Expand Down
50 changes: 48 additions & 2 deletions src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,34 @@ impl UdpSocket {
/// The address type can be any implementor of [`ToSocketAddrs`] trait. See
/// its documentation for concrete examples.
///
/// If `addr` yields multiple addresses, `bind` will be attempted with
/// each of the addresses until one succeeds and returns the socket. If none
/// of the addresses succeed in creating a socket, the error returned from
/// the last attempt (the last address) is returned.
///
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
///
/// # Examples
///
/// Create a UDP socket bound to `127.0.0.1:3400`:
///
/// ```no_run
/// use std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
/// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address");
/// ```
///
/// Create a UDP socket bound to `127.0.0.1:3400`. If the socket cannot be
/// bound to that address, create a UDP socket bound to `127.0.0.1:3401`:
///
/// ```no_run
/// use std::net::{SocketAddr, UdpSocket};
///
/// let addrs = [
/// SocketAddr::from(([127, 0, 0, 1], 3400)),
/// SocketAddr::from(([127, 0, 0, 1], 3401)),
/// ];
/// let socket = UdpSocket::bind(&addrs[..]).expect("couldn't bind to address");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<UdpSocket> {
Expand Down Expand Up @@ -130,6 +150,9 @@ impl UdpSocket {
/// Address type can be any implementor of [`ToSocketAddrs`] trait. See its
/// documentation for concrete examples.
///
/// It is possible for `addr` to yield multiple addresses, but `send_to`
/// will only send data to the first address yielded by `addr`.
///
/// This will return an error when the IP version of the local socket
/// does not match that returned from [`ToSocketAddrs`].
///
Expand Down Expand Up @@ -562,14 +585,37 @@ impl UdpSocket {
/// `recv` syscalls to be used to send data and also applies filters to only
/// receive data from the specified address.
///
/// If `addr` yields multiple addresses, `connect` will be attempted with
/// each of the addresses until a connection is successful. If none of
/// the addresses are able to be connected, the error returned from the
/// last connection attempt (the last address) is returned.
///
/// # Examples
///
/// Create a UDP socket bound to `127.0.0.1:3400` and connect the socket to
/// `127.0.0.1:8080`:
///
/// ```no_run
/// use std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
/// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address");
/// socket.connect("127.0.0.1:8080").expect("connect function failed");
/// ```
///
/// Create a UDP socket bound to `127.0.0.1:3400` and connect the socket to
/// `127.0.0.1:8080`. If that connection fails, then the UDP socket will
/// connect to `127.0.0.1:8081`:
///
/// ```no_run
/// use std::net::{SocketAddr, UdpSocket};
///
/// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address");
/// let connect_addrs = [
/// SocketAddr::from(([127, 0, 0, 1], 8080)),
/// SocketAddr::from(([127, 0, 0, 1], 8081)),
/// ];
/// socket.connect(&connect_addrs[..]).expect("connect function failed");
/// ```
#[stable(feature = "net2_mutators", since = "1.9.0")]
pub fn connect<A: ToSocketAddrs>(&self, addr: A) -> io::Result<()> {
super::each_addr(addr, |addr| self.0.connect(addr))
Expand Down
24 changes: 24 additions & 0 deletions src/test/run-pass/generator/auxiliary/xcrate-reachable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2017 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(conservative_impl_trait, generators, generator_trait)]

use std::ops::Generator;

fn msg() -> u32 {
0
}

pub fn foo() -> impl Generator<Yield=(), Return=u32> {
|| {
yield;
return msg();
}
}
21 changes: 21 additions & 0 deletions src/test/run-pass/generator/xcrate-reachable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2017 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.

// aux-build:xcrate-reachable.rs

#![feature(conservative_impl_trait, generator_trait)]

extern crate xcrate_reachable as foo;

use std::ops::Generator;

fn main() {
foo::foo().resume();
}