Rollup merge of #47510 - sfackler:deprecate-dns, r=alexcrichton

Deprecate std::net::lookup_host

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

r? @alexcrichton
This commit is contained in:
Guillaume Gomez 2018-01-20 22:32:44 +01:00 committed by GitHub
commit 5381dfb7d9
2 changed files with 11 additions and 1 deletions

View File

@ -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};
@ -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();

View File

@ -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() }
@ -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 { .. }")
@ -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)
}