diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-05-23 14:57:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 14:57:55 +0000 |
commit | bf6d540b1043bb944450dfe9da4c91124cdf31d3 (patch) | |
tree | 6edb9359d5ac9d9b63938019e0fd9b336c1dd43e /gcc/rust/backend/rust-compile-pattern.cc | |
parent | 63762cc243c643c10aca7e07dfd6abe9b78748f8 (diff) | |
parent | cd39861da5e1113207193bb8b3e6fb3dde92895f (diff) | |
download | gcc-bf6d540b1043bb944450dfe9da4c91124cdf31d3.zip gcc-bf6d540b1043bb944450dfe9da4c91124cdf31d3.tar.gz gcc-bf6d540b1043bb944450dfe9da4c91124cdf31d3.tar.bz2 |
Merge #1268
1268: Fix Slice Type Layout r=philberty a=philberty
Slices in Rust are represented by TypePaths such as '[i32]'. Though if you
actually try to use this explicit type-path you will hit errors such as
this type has an unknown size at compile time. This is because this is
actually what Rust calls a dynamically sized type. This means when you use
types such as: '&[i32]' it is not actually a reference type to a slice. Its
a slice in its entirety this means for lack of a better word when you use
'*const [i32]' or '&mut [i32]' we end up actually passing around a struct
by value _not_ at pointer/reference to it.
This patch changes the type-layout so that we handle this layout change
properly. This patch will also need to be applied to str types which I
believe have a similar layout for safety.
The patch also sets up TYPE_MAIN_VARIANT so that we can avoid unnessecary
view_convert_expressions between *const [i32] and &mut [i32] which will
have the same layout.
Reference:
https://doc.rust-lang.org/reference/dynamically-sized-types.html
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=672adac002939a2dab43b8d231adc1dc
Fixes #1232
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-pattern.cc')
0 files changed, 0 insertions, 0 deletions