Skip to content

Commit 6e6d080

Browse files
authored
Rollup merge of rust-lang#137809 - Noratrieb:io-error-casing, r=thomcc
Use correct error message casing for `io::const_error`s Error messages are supposed to start with lowercase letters, but a lot of `io::const_error` messages did not. This fixes them to start with a lowercase letter. I did consider adding a const check for this to the macro, but some of them start with proper nouns that make sense to uppercase them. See https://doc.rust-lang.org/1.85.0/std/error/trait.Error.html
2 parents 071d976 + 37cad6d commit 6e6d080

File tree

17 files changed

+75
-75
lines changed

17 files changed

+75
-75
lines changed

Diff for: std/src/io/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Error {
8383

8484
pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_error!(
8585
ErrorKind::NotFound,
86-
"The number of hardware threads is not known for the target platform",
86+
"the number of hardware threads is not known for the target platform",
8787
);
8888

8989
pub(crate) const UNSUPPORTED_PLATFORM: Self =

Diff for: std/src/os/windows/io/socket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl OwnedSocket {
9090

9191
#[cfg(target_vendor = "uwp")]
9292
pub(crate) fn set_no_inherit(&self) -> io::Result<()> {
93-
Err(io::const_error!(io::ErrorKind::Unsupported, "Unavailable on UWP"))
93+
Err(io::const_error!(io::ErrorKind::Unsupported, "unavailable on UWP"))
9494
}
9595
}
9696

Diff for: std/src/sys/net/connection/xous/tcplistener.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ macro_rules! unimpl {
1111
() => {
1212
return Err(io::const_error!(
1313
io::ErrorKind::Unsupported,
14-
"This function is not yet implemented",
14+
"this function is not yet implemented",
1515
));
1616
};
1717
}
@@ -71,7 +71,7 @@ impl TcpListener {
7171
0,
7272
4096,
7373
) else {
74-
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response"));
74+
return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response"));
7575
};
7676

7777
// The first four bytes should be zero upon success, and will be nonzero
@@ -80,15 +80,15 @@ impl TcpListener {
8080
if response[0] != 0 || valid == 0 {
8181
let errcode = response[1];
8282
if errcode == NetError::SocketInUse as u8 {
83-
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use"));
83+
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use"));
8484
} else if errcode == NetError::Invalid as u8 {
85-
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address"));
85+
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address"));
8686
} else if errcode == NetError::LibraryError as u8 {
87-
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
87+
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
8888
} else {
8989
return Err(io::const_error!(
9090
io::ErrorKind::Other,
91-
"Unable to connect or internal error",
91+
"unable to connect or internal error",
9292
));
9393
}
9494
}
@@ -131,7 +131,7 @@ impl TcpListener {
131131
} else if receive_request.raw[1] == NetError::WouldBlock as u8 {
132132
return Err(io::const_error!(io::ErrorKind::WouldBlock, "accept would block"));
133133
} else if receive_request.raw[1] == NetError::LibraryError as u8 {
134-
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
134+
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
135135
} else {
136136
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
137137
}
@@ -169,7 +169,7 @@ impl TcpListener {
169169
Ok((TcpStream::from_listener(stream_fd, self.local.port(), port, addr), addr))
170170
}
171171
} else {
172-
Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to accept"))
172+
Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to accept"))
173173
}
174174
}
175175

@@ -186,7 +186,7 @@ impl TcpListener {
186186
services::net_server(),
187187
services::NetBlockingScalar::StdSetTtlTcp(self.fd.load(Ordering::Relaxed), ttl).into(),
188188
)
189-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
189+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
190190
.map(|_| ())
191191
}
192192

@@ -195,7 +195,7 @@ impl TcpListener {
195195
services::net_server(),
196196
services::NetBlockingScalar::StdGetTtlTcp(self.fd.load(Ordering::Relaxed)).into(),
197197
)
198-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
198+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
199199
.map(|res| res[0] as _)?)
200200
}
201201

Diff for: std/src/sys/net/connection/xous/tcpstream.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ macro_rules! unimpl {
1212
() => {
1313
return Err(io::const_error!(
1414
io::ErrorKind::Unsupported,
15-
"This function is not yet implemented",
15+
"this function is not yet implemented",
1616
));
1717
};
1818
}
@@ -96,7 +96,7 @@ impl TcpStream {
9696
0,
9797
4096,
9898
) else {
99-
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response"));
99+
return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response"));
100100
};
101101

102102
// The first four bytes should be zero upon success, and will be nonzero
@@ -106,13 +106,13 @@ impl TcpStream {
106106
// errcode is a u8 but stuck in a u16 where the upper byte is invalid. Mask & decode accordingly.
107107
let errcode = response[0];
108108
if errcode == NetError::SocketInUse as u8 {
109-
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use"));
109+
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use"));
110110
} else if errcode == NetError::Unaddressable as u8 {
111-
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address"));
111+
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address"));
112112
} else {
113113
return Err(io::const_error!(
114114
io::ErrorKind::InvalidInput,
115-
"Unable to connect or internal error",
115+
"unable to connect or internal error",
116116
));
117117
}
118118
}
@@ -198,7 +198,7 @@ impl TcpStream {
198198
) else {
199199
return Err(io::const_error!(
200200
io::ErrorKind::InvalidInput,
201-
"Library failure: wrong message type or messaging error",
201+
"library failure: wrong message type or messaging error",
202202
));
203203
};
204204

@@ -212,11 +212,11 @@ impl TcpStream {
212212
if result[0] != 0 {
213213
if result[1] == 8 {
214214
// timed out
215-
return Err(io::const_error!(io::ErrorKind::TimedOut, "Timeout"));
215+
return Err(io::const_error!(io::ErrorKind::TimedOut, "timeout"));
216216
}
217217
if result[1] == 9 {
218218
// would block
219-
return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block"));
219+
return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block"));
220220
}
221221
}
222222
Err(io::const_error!(io::ErrorKind::Other, "recv_slice failure"))
@@ -258,20 +258,20 @@ impl TcpStream {
258258
self.write_timeout.load(Ordering::Relaxed) as usize,
259259
buf_len,
260260
)
261-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")))?;
261+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error")))?;
262262

263263
if send_request.raw[0] != 0 {
264264
if send_request.raw[4] == 8 {
265265
// timed out
266266
return Err(io::const_error!(
267267
io::ErrorKind::BrokenPipe,
268-
"Timeout or connection closed",
268+
"timeout or connection closed",
269269
));
270270
} else if send_request.raw[4] == 9 {
271271
// would block
272-
return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block"));
272+
return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block"));
273273
} else {
274-
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Error when sending"));
274+
return Err(io::const_error!(io::ErrorKind::InvalidInput, "error when sending"));
275275
}
276276
}
277277
Ok(u32::from_le_bytes([
@@ -304,7 +304,7 @@ impl TcpStream {
304304
0,
305305
0,
306306
) else {
307-
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error"));
307+
return Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error"));
308308
};
309309
let mut i = get_addr.raw.iter();
310310
match *i.next().unwrap() {
@@ -324,7 +324,7 @@ impl TcpStream {
324324
}
325325
Ok(SocketAddr::V6(SocketAddrV6::new(new_addr.into(), self.local_port, 0, 0)))
326326
}
327-
_ => Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")),
327+
_ => Err(io::const_error!(io::ErrorKind::InvalidInput, "tnternal error")),
328328
}
329329
}
330330

@@ -333,7 +333,7 @@ impl TcpStream {
333333
services::net_server(),
334334
services::NetBlockingScalar::StdTcpStreamShutdown(self.fd, how).into(),
335335
)
336-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
336+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
337337
.map(|_| ())
338338
}
339339

@@ -355,7 +355,7 @@ impl TcpStream {
355355
services::net_server(),
356356
services::NetBlockingScalar::StdSetNodelay(self.fd, enabled).into(),
357357
)
358-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
358+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
359359
.map(|_| ())
360360
}
361361

@@ -364,7 +364,7 @@ impl TcpStream {
364364
services::net_server(),
365365
services::NetBlockingScalar::StdGetNodelay(self.fd).into(),
366366
)
367-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
367+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
368368
.map(|res| res[0] != 0)?)
369369
}
370370

@@ -376,7 +376,7 @@ impl TcpStream {
376376
services::net_server(),
377377
services::NetBlockingScalar::StdSetTtlTcp(self.fd, ttl).into(),
378378
)
379-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
379+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
380380
.map(|_| ())
381381
}
382382

@@ -385,7 +385,7 @@ impl TcpStream {
385385
services::net_server(),
386386
services::NetBlockingScalar::StdGetTtlTcp(self.fd).into(),
387387
)
388-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
388+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
389389
.map(|res| res[0] as _)?)
390390
}
391391

Diff for: std/src/sys/net/connection/xous/udp.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ macro_rules! unimpl {
1313
() => {
1414
return Err(io::const_error!(
1515
io::ErrorKind::Unsupported,
16-
"This function is not yet implemented",
16+
"this function is not yet implemented",
1717
));
1818
};
1919
}
@@ -72,18 +72,18 @@ impl UdpSocket {
7272
if response[0] != 0 || valid == 0 {
7373
let errcode = response[1];
7474
if errcode == NetError::SocketInUse as u8 {
75-
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use"));
75+
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use"));
7676
} else if errcode == NetError::Invalid as u8 {
7777
return Err(io::const_error!(
7878
io::ErrorKind::InvalidInput,
79-
"Port can't be 0 or invalid address",
79+
"port can't be 0 or invalid address",
8080
));
8181
} else if errcode == NetError::LibraryError as u8 {
82-
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
82+
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
8383
} else {
8484
return Err(io::const_error!(
8585
io::ErrorKind::Other,
86-
"Unable to connect or internal error",
86+
"unable to connect or internal error",
8787
));
8888
}
8989
}
@@ -98,13 +98,13 @@ impl UdpSocket {
9898
nonblocking: Cell::new(false),
9999
});
100100
}
101-
Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response"))
101+
Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response"))
102102
}
103103

104104
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
105105
match self.remote.get() {
106106
Some(dest) => Ok(dest),
107-
None => Err(io::const_error!(io::ErrorKind::NotConnected, "No peer specified")),
107+
None => Err(io::const_error!(io::ErrorKind::NotConnected, "no peer specified")),
108108
}
109109
}
110110

@@ -145,7 +145,7 @@ impl UdpSocket {
145145
} else if receive_request.raw[1] == NetError::WouldBlock as u8 {
146146
return Err(io::const_error!(io::ErrorKind::WouldBlock, "recv would block"));
147147
} else if receive_request.raw[1] == NetError::LibraryError as u8 {
148-
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
148+
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
149149
} else {
150150
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
151151
}
@@ -178,7 +178,7 @@ impl UdpSocket {
178178
Ok((rxlen as usize, addr))
179179
}
180180
} else {
181-
Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to recv"))
181+
Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to recv"))
182182
}
183183
}
184184

@@ -281,19 +281,19 @@ impl UdpSocket {
281281
if errcode == NetError::SocketInUse as u8 {
282282
return Err(io::const_error!(
283283
io::ErrorKind::ResourceBusy,
284-
"Socket in use",
284+
"socket in use",
285285
));
286286
} else if errcode == NetError::Invalid as u8 {
287287
return Err(io::const_error!(
288288
io::ErrorKind::InvalidInput,
289-
"Socket not valid",
289+
"socket not valid",
290290
));
291291
} else if errcode == NetError::LibraryError as u8 {
292-
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
292+
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
293293
} else {
294294
return Err(io::const_error!(
295295
io::ErrorKind::Other,
296-
"Unable to connect",
296+
"unable to connect",
297297
));
298298
}
299299
} else {
@@ -303,13 +303,13 @@ impl UdpSocket {
303303
}
304304
Err(crate::os::xous::ffi::Error::ServerQueueFull) => {
305305
if now.elapsed() >= write_timeout {
306-
return Err(io::const_error!(io::ErrorKind::WouldBlock, "Write timed out"));
306+
return Err(io::const_error!(io::ErrorKind::WouldBlock, "write timed out"));
307307
} else {
308308
// question: do we want to do something a bit more gentle than immediately retrying?
309309
crate::thread::yield_now();
310310
}
311311
}
312-
_ => return Err(io::const_error!(io::ErrorKind::Other, "Library error")),
312+
_ => return Err(io::const_error!(io::ErrorKind::Other, "library error")),
313313
}
314314
}
315315
}
@@ -363,7 +363,7 @@ impl UdpSocket {
363363
services::net_server(),
364364
services::NetBlockingScalar::StdSetTtlUdp(self.fd, ttl).into(),
365365
)
366-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
366+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
367367
.map(|_| ())
368368
}
369369

@@ -372,7 +372,7 @@ impl UdpSocket {
372372
services::net_server(),
373373
services::NetBlockingScalar::StdGetTtlUdp(self.fd).into(),
374374
)
375-
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
375+
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
376376
.map(|res| res[0] as _)?)
377377
}
378378

Diff for: std/src/sys/pal/hermit/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Thread {
4141
unsafe {
4242
drop(Box::from_raw(p));
4343
}
44-
Err(io::const_error!(io::ErrorKind::Uncategorized, "Unable to create thread!"))
44+
Err(io::const_error!(io::ErrorKind::Uncategorized, "unable to create thread!"))
4545
} else {
4646
Ok(Thread { tid })
4747
};

0 commit comments

Comments
 (0)