Skip to content
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

Rollup of 9 pull requests #59244

Closed
wants to merge 31 commits into from
Closed
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9aa89b2
When encountetring `||{}()`, suggest the likely intended `(||{})()`
estebank Mar 9, 2019
94a6936
Track embedded-book in the toolstate
kennytm Mar 9, 2019
135b686
Update src/tools/publish_toolstate.py
jamesmunns Mar 10, 2019
d6f5100
Fix tidy
kennytm Mar 10, 2019
8353487
refactor build-mainfest.
Centril Mar 7, 2019
7e1914f
hir: replace NodeId with HirId in trait_impls
ljedrz Mar 10, 2019
401329e
HirIdification: remove all NodeIds from borrowck
ljedrz Mar 10, 2019
aa53741
HirIdification: remove all NodeIds from typeck
ljedrz Mar 10, 2019
9151eab
HirIdification: remove all NodeIds from rustc_mir
ljedrz Mar 10, 2019
584d61a
hir: remove trait_auto_impl
ljedrz Mar 10, 2019
b9d12ed
Be more discerning on when to attempt suggesting a comma in a macro i…
estebank Mar 11, 2019
27abd52
Fix operator precedence
estebank Mar 13, 2019
856b081
middle: replace NodeId with HirId in AccessLevels
ljedrz Mar 11, 2019
4e5692d
test that wildcard type `_` is not duplicated by `type Foo<X> = (X, X…
pnkfelix Jan 18, 2019
a7bd36c
Add peer_addr function to UdpSocket
LinusU Mar 11, 2019
bf473e3
Mark UdpSocket peer_addr unstable w/ tracking issue
LinusU Mar 12, 2019
24e3fa0
Document UdpSocket peer_addr NotConnected error
LinusU Mar 12, 2019
7f7cfae
Add test for UdpSocket peer_addr
LinusU Mar 12, 2019
7e73cd4
Fix test names regarding ip version
LinusU Mar 12, 2019
214110b
Add UdpSocket peer_addr implementation for L4Re
LinusU Mar 16, 2019
81d5fb5
Add UdpSocket peer_addr implementation for Wasm
LinusU Mar 16, 2019
47ee538
resolve: Account for new importable entities
petrochenkov Mar 9, 2019
8c84630
Rollup merge of #57729 - pnkfelix:issue-55748-pat-types-are-constrain…
Centril Mar 16, 2019
bc7b660
Rollup merge of #58995 - Centril:refactor-build-manifest, r=alexcrichton
Centril Mar 16, 2019
5ae8b97
Rollup merge of #59035 - estebank:closure-instacall, r=davidtwco
Centril Mar 16, 2019
aa3ada8
Rollup merge of #59038 - kennytm:track-embedded-book, r=oli-obk
Centril Mar 16, 2019
657cb3f
Rollup merge of #59047 - petrochenkov:modnodefid, r=Centril
Centril Mar 16, 2019
cadb47c
Rollup merge of #59068 - ljedrz:kill_off_NodeId_stragglers, r=Zoxc
Centril Mar 16, 2019
f0cdccd
Rollup merge of #59096 - ljedrz:HirIdify_AccessLevel, r=Zoxc
Centril Mar 16, 2019
6656fe5
Rollup merge of #59106 - LinusU:udp-peer-addr, r=kennytm
Centril Mar 16, 2019
1729852
Rollup merge of #59116 - estebank:comma-sugg, r=petrochenkov
Centril Mar 16, 2019
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
43 changes: 42 additions & 1 deletion src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
@@ -180,6 +180,37 @@ impl UdpSocket {
}
}

/// Returns the socket address of the remote peer this socket was connected to.
///
/// # Examples
///
/// ```no_run
/// #![feature(udp_peer_addr)]
/// use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, UdpSocket};
///
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
/// socket.connect("192.168.0.1:41203").expect("couldn't connect to address");
/// assert_eq!(socket.peer_addr().unwrap(),
/// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203)));
/// ```
///
/// If the socket isn't connected, it will return a [`NotConnected`] error.
///
/// [`NotConnected`]: ../../std/io/enum.ErrorKind.html#variant.NotConnected
///
/// ```no_run
/// #![feature(udp_peer_addr)]
/// use std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
/// assert_eq!(socket.peer_addr().unwrap_err().kind(),
/// ::std::io::ErrorKind::NotConnected);
/// ```
#[unstable(feature = "udp_peer_addr", issue = "59127")]
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
self.0.peer_addr()
}

/// Returns the socket address that this socket was created from.
///
/// # Examples
@@ -865,13 +896,23 @@ mod tests {
}

#[test]
fn socket_name_ip4() {
fn socket_name() {
each_ip(&mut |addr, _| {
let server = t!(UdpSocket::bind(&addr));
assert_eq!(addr, t!(server.local_addr()));
})
}

#[test]
fn socket_peer() {
each_ip(&mut |addr1, addr2| {
let server = t!(UdpSocket::bind(&addr1));
assert_eq!(server.peer_addr().unwrap_err().kind(), ErrorKind::NotConnected);
t!(server.connect(&addr2));
assert_eq!(addr2, t!(server.peer_addr()));
})
}

#[test]
fn udp_clone_smoke() {
each_ip(&mut |addr1, addr2| {
4 changes: 4 additions & 0 deletions src/libstd/sys/cloudabi/shims/net.rs
Original file line number Diff line number Diff line change
@@ -159,6 +159,10 @@ impl UdpSocket {
unsupported()
}

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
match self.0 {}
}

pub fn socket_addr(&self) -> io::Result<SocketAddr> {
match self.0 {}
}
5 changes: 5 additions & 0 deletions src/libstd/sys/redox/net/udp.rs
Original file line number Diff line number Diff line change
@@ -72,6 +72,11 @@ impl UdpSocket {
Ok(None)
}

pub fn peer_addr(&self) -> Result<SocketAddr> {
let path = self.0.path()?;
Ok(path_to_peer_addr(path.to_str().unwrap_or("")))
}

pub fn socket_addr(&self) -> Result<SocketAddr> {
let path = self.0.path()?;
Ok(path_to_local_addr(path.to_str().unwrap_or("")))
4 changes: 4 additions & 0 deletions src/libstd/sys/sgx/net.rs
Original file line number Diff line number Diff line change
@@ -249,6 +249,10 @@ impl UdpSocket {
unsupported()
}

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
match self.0 {}
}

pub fn socket_addr(&self) -> io::Result<SocketAddr> {
match self.0 {}
}
5 changes: 4 additions & 1 deletion src/libstd/sys/unix/l4re.rs
Original file line number Diff line number Diff line change
@@ -292,6 +292,10 @@ pub mod net {

pub fn into_socket(self) -> Socket { self.inner }

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
unimpl!();
}

pub fn socket_addr(&self) -> io::Result<SocketAddr> {
unimpl!();
}
@@ -463,4 +467,3 @@ pub mod net {
}
}
}

4 changes: 4 additions & 0 deletions src/libstd/sys/wasm/net.rs
Original file line number Diff line number Diff line change
@@ -156,6 +156,10 @@ impl UdpSocket {
unsupported()
}

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
match self.0 {}
}

pub fn socket_addr(&self) -> io::Result<SocketAddr> {
match self.0 {}
}
6 changes: 6 additions & 0 deletions src/libstd/sys_common/net.rs
Original file line number Diff line number Diff line change
@@ -472,6 +472,12 @@ impl UdpSocket {

pub fn into_socket(self) -> Socket { self.inner }

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
sockname(|buf, len| unsafe {
c::getpeername(*self.inner.as_inner(), buf, len)
})
}

pub fn socket_addr(&self) -> io::Result<SocketAddr> {
sockname(|buf, len| unsafe {
c::getsockname(*self.inner.as_inner(), buf, len)