From f80383ceaa629b02107cfbf90316ed124da869a7 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Thu, 18 Aug 2022 16:04:00 -0700 Subject: [PATCH] Inline `>::from` I noticed in the MIR for that it's inlined most stuff ``` scope 5 (inlined as Try>::branch) ``` ``` scope 8 (inlined as Try>::from_output) ``` But yet the do-nothing `from` call was still there: ``` _17 = >::from(move _18) -> bb9; ``` So let's give this a try and see what perf has to say. --- core/src/convert/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/convert/mod.rs b/core/src/convert/mod.rs index b30c8a4ae..ff10a243d 100644 --- a/core/src/convert/mod.rs +++ b/core/src/convert/mod.rs @@ -556,6 +556,7 @@ where #[rustc_const_unstable(feature = "const_convert", issue = "88674")] impl const From for T { /// Returns the argument unchanged. + #[inline(always)] fn from(t: T) -> T { t }