public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Merge #1268
@ 2022-06-08 12:49 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bf6d540b1043bb944450dfe9da4c91124cdf31d3

commit bf6d540b1043bb944450dfe9da4c91124cdf31d3
Merge: 63762cc243c cd39861da5e
Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Date:   Mon May 23 14:57:55 2022 +0000

    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>

Diff:

 gcc/rust/backend/rust-compile-context.h          |  12 ++
 gcc/rust/backend/rust-compile-expr.cc            |  56 +++++++-
 gcc/rust/backend/rust-compile-type.cc            |  82 +++++++++---
 gcc/rust/backend/rust-compile-type.h             |   8 +-
 gcc/rust/backend/rust-compile.cc                 |  19 +++
 gcc/rust/backend/rust-tree.h                     |   6 +
 gcc/rust/typecheck/rust-tyty.h                   |  30 +++++
 gcc/testsuite/rust/execute/torture/issue-1232.rs | 159 +++++++++++++++++++++++
 8 files changed, 345 insertions(+), 27 deletions(-)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:49 [gcc/devel/rust/master] Merge #1268 Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).