Skip to content

Commit

Permalink
Rollup merge of rust-lang#47510 - sfackler:deprecate-dns, r=alexcrichton
Browse files Browse the repository at this point in the history
Deprecate std::net::lookup_host

We intended to do this quite a while ago but it snuck through.

r? @alexcrichton
  • Loading branch information
GuillaumeGomez authored Jan 19, 2018
2 parents c71ea45 + 908aa38 commit c71bc78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use fmt;
use hash;
use io;
use mem;
use net::{lookup_host, ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
use net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
#[allow(deprecated)]
use net::lookup_host;
use option;
use sys::net::netc as c;
use sys_common::{FromInner, AsInner, IntoInner};
Expand Down Expand Up @@ -845,6 +847,7 @@ impl ToSocketAddrs for (Ipv6Addr, u16) {
}
}

#[allow(deprecated)]
fn resolve_socket_addr(s: &str, p: u16) -> io::Result<vec::IntoIter<SocketAddr>> {
let ips = lookup_host(s)?;
let v: Vec<_> = ips.map(|mut a| { a.set_port(p); a }).collect();
Expand Down
7 changes: 7 additions & 0 deletions src/libstd/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,15 @@ fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T>
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
pub struct LookupHost(net_imp::LookupHost);

#[unstable(feature = "lookup_host", reason = "unsure about the returned \
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
#[allow(deprecated)]
impl Iterator for LookupHost {
type Item = SocketAddr;
fn next(&mut self) -> Option<SocketAddr> { self.0.next() }
Expand All @@ -149,6 +152,8 @@ impl Iterator for LookupHost {
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
#[allow(deprecated)]
impl fmt::Debug for LookupHost {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("LookupHost { .. }")
Expand Down Expand Up @@ -181,6 +186,8 @@ impl fmt::Debug for LookupHost {
iterator and returning socket \
addresses",
issue = "27705")]
#[rustc_deprecated(since = "1.25", reason = "Use the ToSocketAddrs trait instead")]
#[allow(deprecated)]
pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
net_imp::lookup_host(host).map(LookupHost)
}

0 comments on commit c71bc78

Please sign in to comment.