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

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


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

only message in thread, other threads:[~2022-06-08 12:50 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:50 [gcc/devel/rust/master] Merge #1280 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).