Skip to content

Commit

Permalink
Auto merge of rust-lang#100733 - scottmcm:inline-from-from-identity, …
Browse files Browse the repository at this point in the history
…r=m-ou-se

Inline `<T as From<T>>::from`

I noticed (in rust-lang#100693 (comment)) 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.
  • Loading branch information
bors committed Sep 6, 2022
2 parents 3c72788 + 8118a31 commit 380addd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 380addd

Please sign in to comment.