Skip to content

Commit 496f026

Browse files
authored
Rollup merge of rust-lang#49702 - alexcrichton:inline-methods, r=Mark-Simulacrum
std: Inline some Termination-related methods These were showing up in tests and in binaries but are trivially optimize-able away, so add `#[inline]` attributes so LLVM has an opportunity to optimize them out.
2 parents 91e81fa + 323f808 commit 496f026

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

src/libstd/process.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@ pub trait Termination {
14521452

14531453
#[unstable(feature = "termination_trait_lib", issue = "43301")]
14541454
impl Termination for () {
1455+
#[inline]
14551456
fn report(self) -> i32 { ExitCode::SUCCESS.report() }
14561457
}
14571458

@@ -1481,6 +1482,7 @@ impl<E: fmt::Debug> Termination for Result<!, E> {
14811482

14821483
#[unstable(feature = "termination_trait_lib", issue = "43301")]
14831484
impl Termination for ExitCode {
1485+
#[inline]
14841486
fn report(self) -> i32 {
14851487
self.0.as_i32()
14861488
}

src/libstd/sys/unix/process/process_common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ impl ExitCode {
404404
pub const SUCCESS: ExitCode = ExitCode(EXIT_SUCCESS as _);
405405
pub const FAILURE: ExitCode = ExitCode(EXIT_FAILURE as _);
406406

407+
#[inline]
407408
pub fn as_i32(&self) -> i32 {
408409
self.0 as i32
409410
}

src/libstd/sys/windows/process.rs

+1
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl ExitCode {
414414
pub const SUCCESS: ExitCode = ExitCode(EXIT_SUCCESS as _);
415415
pub const FAILURE: ExitCode = ExitCode(EXIT_FAILURE as _);
416416

417+
#[inline]
417418
pub fn as_i32(&self) -> i32 {
418419
self.0 as i32
419420
}

0 commit comments

Comments
 (0)