Skip to content

Commit 7d6af67

Browse files
authored
Rollup merge of #83555 - m-ou-se:inline-io-error-new-const, r=jackh726
Add #[inline] to io::Error methods Fixes #82812
2 parents 1115acc + ee1b33c commit 7d6af67

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/std/src/io/error.rs

+8
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ impl Error {
269269
/// This function should maybe change to
270270
/// `new_const<const MSG: &'static str>(kind: ErrorKind)`
271271
/// in the future, when const generics allow that.
272+
#[inline]
272273
pub(crate) const fn new_const(kind: ErrorKind, message: &'static &'static str) -> Error {
273274
Self { repr: Repr::SimpleMessage(kind, message) }
274275
}
@@ -287,6 +288,7 @@ impl Error {
287288
/// println!("last OS error: {:?}", Error::last_os_error());
288289
/// ```
289290
#[stable(feature = "rust1", since = "1.0.0")]
291+
#[inline]
290292
pub fn last_os_error() -> Error {
291293
Error::from_raw_os_error(sys::os::errno() as i32)
292294
}
@@ -317,6 +319,7 @@ impl Error {
317319
/// # }
318320
/// ```
319321
#[stable(feature = "rust1", since = "1.0.0")]
322+
#[inline]
320323
pub fn from_raw_os_error(code: i32) -> Error {
321324
Error { repr: Repr::Os(code) }
322325
}
@@ -351,6 +354,7 @@ impl Error {
351354
/// }
352355
/// ```
353356
#[stable(feature = "rust1", since = "1.0.0")]
357+
#[inline]
354358
pub fn raw_os_error(&self) -> Option<i32> {
355359
match self.repr {
356360
Repr::Os(i) => Some(i),
@@ -388,6 +392,7 @@ impl Error {
388392
/// }
389393
/// ```
390394
#[stable(feature = "io_error_inner", since = "1.3.0")]
395+
#[inline]
391396
pub fn get_ref(&self) -> Option<&(dyn error::Error + Send + Sync + 'static)> {
392397
match self.repr {
393398
Repr::Os(..) => None,
@@ -460,6 +465,7 @@ impl Error {
460465
/// }
461466
/// ```
462467
#[stable(feature = "io_error_inner", since = "1.3.0")]
468+
#[inline]
463469
pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)> {
464470
match self.repr {
465471
Repr::Os(..) => None,
@@ -497,6 +503,7 @@ impl Error {
497503
/// }
498504
/// ```
499505
#[stable(feature = "io_error_inner", since = "1.3.0")]
506+
#[inline]
500507
pub fn into_inner(self) -> Option<Box<dyn error::Error + Send + Sync>> {
501508
match self.repr {
502509
Repr::Os(..) => None,
@@ -525,6 +532,7 @@ impl Error {
525532
/// }
526533
/// ```
527534
#[stable(feature = "rust1", since = "1.0.0")]
535+
#[inline]
528536
pub fn kind(&self) -> ErrorKind {
529537
match self.repr {
530538
Repr::Os(code) => sys::decode_error_kind(code),

0 commit comments

Comments
 (0)