diff options
| author | bors <bors@rust-lang.org> | 2022-09-06 14:33:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-06 14:33:31 +0000 |
| commit | 380addd7d2971447d7f6828c508a93fa8018a9b6 (patch) | |
| tree | 29b4ea9db78492ef7c2149abbeb49b7bca23cf22 | |
| parent | 3c7278846102bb829c9a789e91bc43f0ed612943 (diff) | |
| parent | 8118a31e86ac0f468e47a3ba794b01c8e36db25d (diff) | |
| download | rust-380addd7d2971447d7f6828c508a93fa8018a9b6.tar.gz rust-380addd7d2971447d7f6828c508a93fa8018a9b6.zip | |
Auto merge of #100733 - scottmcm:inline-from-from-identity, r=m-ou-se
Inline `<T as From<T>>::from` I noticed (in https://github.com/rust-lang/rust/pull/100693#issuecomment-1218520141) that the MIR for <https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=67097e0494363ee27421a4e3bdfaf513> has inlined most stuff ``` scope 5 (inlined <Result<i32, u32> as Try>::branch) ``` ``` scope 8 (inlined <Result<i32, u32> as Try>::from_output) ``` But yet the do-nothing `from` call was still there: ``` _17 = <u32 as From<u32>>::from(move _18) -> bb9; ``` So let's give this a try and see what perf has to say.
| -rw-r--r-- | library/core/src/convert/mod.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 5bddfd1a413..05637c16622 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -558,6 +558,7 @@ where #[rustc_const_unstable(feature = "const_convert", issue = "88674")] impl<T> const From<T> for T { /// Returns the argument unchanged. + #[inline(always)] fn from(t: T) -> T { t } |
