public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] Merge #1280
Date: Wed,  8 Jun 2022 12:50:45 +0000 (GMT)	[thread overview]
Message-ID: <20220608125045.16082388B596@sourceware.org> (raw)

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

commit a4455d8f522cad015f3540f118f8c6ce2775fccb
Merge: 5c84a5ca514 4cfd6942c07
Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Date:   Thu May 26 08:55:57 2022 +0000

    Merge #1280
    
    1280: Str's have the same layout as [T] r=philberty a=philberty
    
    Raw strings have a very specific type layout which maps over to Slices. It
    also has very specific type checking rules so for example:
    
        let a:&str = "TEST 1";
        let b:&str = &"TEST 2";
    
    Are both the same type this is likely to be for all DST's but lets do one
    rule at a time.
    
    Fixes #1023 #1271
    
    Co-authored-by: Philip Herron <philip.herron@embecosm.com>

Diff:

 gcc/rust/backend/rust-compile-expr.cc             |  19 +++-
 gcc/rust/backend/rust-compile-type.cc             |  54 ++++++++++-
 gcc/rust/backend/rust-compile-type.h              |   1 +
 gcc/rust/backend/rust-compile.cc                  |  31 +++---
 gcc/rust/typecheck/rust-hir-type-check-expr.h     |  20 ++++
 gcc/rust/typecheck/rust-tycheck-dump.h            |   8 ++
 gcc/rust/typecheck/rust-tyty.h                    | 112 ++++++++++++++--------
 gcc/testsuite/rust/compile/issue-1023.rs          |   4 +
 gcc/testsuite/rust/compile/issue-1271.rs          |   5 +
 gcc/testsuite/rust/compile/xfail/slice1.rs        |   5 -
 gcc/testsuite/rust/execute/torture/str-layout1.rs |  56 +++++++++++
 11 files changed, 249 insertions(+), 66 deletions(-)

diff --cc gcc/rust/typecheck/rust-hir-type-check-expr.h
index 9dcae0871ca,d895ce43d37..8427cc9afc4
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h
@@@ -923,8 -972,28 +923,28 @@@ public
    void visit (HIR::BorrowExpr &expr) override
    {
      TyTy::BaseType *resolved_base
 -      = TypeCheckExpr::Resolve (expr.get_expr ().get (), false);
 +      = TypeCheckExpr::Resolve (expr.get_expr ().get ());
  
+     // In Rust this is valid because of DST's
+     //
+     // fn test() {
+     //     let a:&str = "TEST 1";
+     //     let b:&str = &"TEST 2";
+     // }
+     if (resolved_base->get_kind () == TyTy::TypeKind::REF)
+       {
+ 	const TyTy::ReferenceType *ref
+ 	  = static_cast<const TyTy::ReferenceType *> (resolved_base);
+ 
+ 	// this might end up being a more generic is_dyn object check but lets
+ 	// double check dyn traits type-layout first
+ 	if (ref->is_dyn_str_type ())
+ 	  {
+ 	    infered = resolved_base;
+ 	    return;
+ 	  }
+       }
+ 
      if (expr.get_is_double_borrow ())
        {
  	// FIXME double_reference


                 reply	other threads:[~2022-06-08 12:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608125045.16082388B596@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).