Skip to content

Commit

Permalink
Auto merge of #117510 - elichai:patch-3, r=cuviper
Browse files Browse the repository at this point in the history
Add track_caller to transmute_copy

Currently if `size_of::<Src>() < size_of::<Dst>()` you will see the following error:
```rust
thread 'test' panicked at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/mem/mod.rs:1056:5:
cannot transmute_copy if Dst is larger than Src
```
This fixes it so it will show the invocation location
  • Loading branch information
bors committed Nov 3, 2023
2 parents 1d6f05f + 5e49a41 commit 4911224
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ pub const fn copy<T: Copy>(x: &T) -> T {
/// ```
#[inline]
#[must_use]
#[track_caller]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_transmute_copy", since = "1.74.0")]
pub const unsafe fn transmute_copy<Src, Dst>(src: &Src) -> Dst {
Expand Down

0 comments on commit 4911224

Please sign in to comment.