Skip to content

Commit b74ec4c

Browse files
committed
Auto merge of #27976 - sfackler:addrparseerror-error, r=alexcrichton
Closes #27973
2 parents 797d0ba + f266f12 commit b74ec4c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/libstd/net/parser.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
1616
use prelude::v1::*;
1717

18-
use str::FromStr;
18+
use error::Error;
19+
use fmt;
1920
use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
21+
use str::FromStr;
2022

2123
struct Parser<'a> {
2224
// parsing as ASCII, so can use byte array
@@ -339,3 +341,17 @@ impl FromStr for SocketAddr {
339341
#[stable(feature = "rust1", since = "1.0.0")]
340342
#[derive(Debug, Clone, PartialEq)]
341343
pub struct AddrParseError(());
344+
345+
#[stable(feature = "addr_parse_error_error", since = "1.4.0")]
346+
impl fmt::Display for AddrParseError {
347+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
348+
fmt.write_str(self.description())
349+
}
350+
}
351+
352+
#[stable(feature = "addr_parse_error_error", since = "1.4.0")]
353+
impl Error for AddrParseError {
354+
fn description(&self) -> &str {
355+
"invalid IP address syntax"
356+
}
357+
}

0 commit comments

Comments
 (0)